@@ -29,72 +29,78 @@
# include "QGlobals.h"
vtkStandardNewMacro ( ActorDraggableInteractorStyle ) ;
ActorDraggableInteractorStyle : : ActorDraggableInteractorStyle ( ) {
this - > AddObserver ( vtkCommand : : InteractionEvent , this , & ActorDraggableInteractorStyle : : DispatchEvent ) ;
this - > AddObserver ( vtkCommand : : InteractionEvent , this , & ActorDraggableInteractorStyle : : DispatchEvent ) ;
# ifdef _DEBUG
this - > AddObserver ( DraggableStyleEvents : : EndDollyEvent , this , & ActorDraggableInteractorStyle : : TestOutPut ) ;
this - > AddObserver ( vtkCommand : : EventIds : : EndPanEvent , this , & ActorDraggableInteractorStyle : : TestOutPut ) ;
this - > AddObserver ( vtkCommand : : EventIds : : EndRotateEvent , this , & ActorDraggableInteractorStyle : : TestOutPut ) ;
this - > AddObserver ( vtkCommand : : EventIds : : EndWindowLevelEvent , this , & ActorDraggableInteractorStyle : : TestOutPut ) ;
this - > AddObserver ( DraggableStyleEvents : : SlicedEvent , this , & ActorDraggableInteractorStyle : : TestOutPut ) ;
this - > AddObserver ( DraggableStyleEvents : : EndDollyEvent , this , & ActorDraggableInteractorStyle : : TestOutPut ) ;
this - > AddObserver ( vtkCommand : : EventIds : : EndPanEvent , this , & ActorDraggableInteractorStyle : : TestOutPut ) ;
this - > AddObserver ( vtkCommand : : EventIds : : EndRotateEvent , this , & ActorDraggableInteractorStyle : : TestOutPut ) ;
this - > AddObserver ( vtkCommand : : EventIds : : EndWindowLevelEvent , this , & ActorDraggableInteractorStyle : : TestOutPut ) ;
this - > AddObserver ( DraggableStyleEvents : : SlicedEvent , this , & ActorDraggableInteractorStyle : : TestOutPut ) ;
# endif
}
ActorDraggableInteractorStyle : : ~ ActorDraggableInteractorStyle ( ) {
if ( scalarProp ) {
scalarProp - > Delete ( ) ;
scalarProp = nullptr ;
}
if ( CornerAnnotation ) {
CornerAnnotation - > UnRegister ( this ) ;
}
}
template < typename T >
void vtkValueMessageTemplate ( vtkImageData * image , int * position , std : : string & message )
{
T * tuple = ( ( T * ) image - > GetScalarPointer ( position ) ) ;
if ( ! tuple )
{
return ;
}
int components = image - > GetNumberOfScalarComponents ( ) ;
for ( int c = 0 ; c < components ; + + c )
{
message + = vtkVariant ( tuple [ c ] ) . ToString ( ) ;
if ( c ! = ( components - 1 ) )
{
message + = " , " ;
}
}
//message += " )";
T * tuple = ( ( T * ) image - > GetScalarPointer ( position ) ) ;
if ( ! tuple )
{
return ;
}
int components = image - > GetNumberOfScalarComponents ( ) ;
for ( int c = 0 ; c < components ; + + c )
{
message + = vtkVariant ( tuple [ c ] ) . ToString ( ) ;
if ( c ! = ( components - 1 ) )
{
message + = " , " ;
}
}
//message += " )";
}
void ActorDraggableInteractorStyle : : OnLeftButtonUp ( ) {
switch ( this - > State ) {
case VTKIS_DRAG :
DraggableActor : : SafeDownCast ( dragProp ) - > ApplyTransform ( ) ;
this - > EndDrag ( ) ;
break ;
case VTKIS_MEASURE :
measure - > SetPlacing ( measure - > onMeasureLeftButtonUp ( this - > Interactor ) ) ;
if ( ! measure - > isMeasurePlacing ( ) ) {
this - > EndMeasure ( ) ;
auto temp = measure ;
measure = measure - > GetNextMeasure ( ) ;
if ( ! temp - > Valid ( ) ) {
temp - > ForceDelete ( ) ;
temp = nullptr ;
}
}
break ;
case VTKIS_COLORMAP :
this - > EndColorMapping ( ) ;
break ;
}
vtkInteractorStyleImage : : OnLeftButtonUp ( ) ;
switch ( this - > State ) {
case VTKIS_DRAG :
DraggableActor : : SafeDownCast ( dragProp ) - > ApplyTransform ( ) ;
this - > EndDrag ( ) ;
break ;
case VTKIS_MEASURE :
measure - > SetPlacing ( measure - > onMeasureLeftButtonUp ( this - > Interactor ) ) ;
if ( ! measure - > isMeasurePlacing ( ) ) {
this - > EndMeasure ( ) ;
auto temp = measure ;
measure = measure - > GetNextMeasure ( ) ;
if ( ! temp - > Valid ( ) ) {
temp - > ForceDelete ( ) ;
temp = nullptr ;
}
}
break ;
case VTKIS_COLORMAP :
this - > EndColorMapping ( ) ;
break ;
}
vtkInteractorStyleImage : : OnLeftButtonUp ( ) ;
}
void ActorDraggableInteractorStyle : : ColorMapping ( )
void ActorDraggableInteractorStyle : : ColorMapping ( )
{
vtkRenderWindowInteractor * rwi = this - > Interactor ;
vtkRenderWindowInteractor * rwi = this - > Interactor ;
this - > ScalarCurrentPosition [ 1 ] = rwi - > GetEventPosition ( ) [ 1 ] ;
//pos[0] = (this->ScalarCurrentPosition[0] - this->ScalarStartPosition[0]);
double total = 0.01 * ( ( this - > ScalarCurrentPosition [ 1 ] - this - > ScalarStartPosition [ 1 ] ) / scalarSensitivity ) ;
double total = 0.01 * ( ( this - > ScalarCurrentPosition [ 1 ] - this - > ScalarStartPosition [ 1 ] ) / scalarSensitivity ) ;
double left = total - ConsumedOpacity ;
//printf("ColorMapping:%d,%d,%.2f \r\n", ScalarCurrentPosition[1], ScalarStartPosition[1],left);
if ( abs ( left ) > = 0.01 ) {
@@ -120,15 +126,15 @@ void ActorDraggableInteractorStyle::EndColorMapping()
void ActorDraggableInteractorStyle : : Drag ( ) {
int * pos = this - > Interactor - > GetEventPosition ( ) ;
this - > FindPokedRenderer ( pos [ 0 ] , pos [ 1 ] ) ;
DraggableActor : : SafeDownCast ( dragProp ) - > Transform ( pos [ 0 ] - DragStartOrigin [ 0 ] , pos [ 1 ] - DragStartOrigin [ 1 ] ) ;
this - > Interactor - > Render ( ) ;
int * pos = this - > Interactor - > GetEventPosition ( ) ;
this - > FindPokedRenderer ( pos [ 0 ] , pos [ 1 ] ) ;
DraggableActor : : SafeDownCast ( dragProp ) - > Transform ( pos [ 0 ] - DragStartOrigin [ 0 ] , pos [ 1 ] - DragStartOrigin [ 1 ] ) ;
this - > Interactor - > Render ( ) ;
}
void ActorDraggableInteractorStyle : : MeasurePlace ( ) {
measure - > onMeasureMouseMove ( this - > Interactor ) ;
measure - > onMeasureMouseMove ( this - > Interactor ) ;
}
void ActorDraggableInteractorStyle : : NoneStatePick ( ) {
@@ -141,7 +147,7 @@ void ActorDraggableInteractorStyle::NoneStatePick() {
if ( result )
{
vtkProp * obj = picker - > GetViewProp ( ) ;
vtkProp * obj = picker - > GetViewProp ( ) ;
if ( scalarProp ! = obj & & scalarProp ) {
scalarProp = nullptr ;
}
@@ -205,11 +211,11 @@ void ActorDraggableInteractorStyle::NoneStatePick() {
scalarProp = nullptr ;
}
dragProp = nullptr ;
this - > CornerAnnotation - > SetText ( BOTTOM_LEFT , " " ) ;
if ( this - > CornerAnnotation ) this- > CornerAnnotation - > SetText ( BOTTOM_LEFT , " " ) ;
}
}
this - > CornerAnnotation - > SetText ( BOTTOM_LEFT , " " ) ;
this - > Interactor - > Render ( ) ;
if ( this - > CornerAnnotation ) this- > CornerAnnotation - > SetText ( BOTTOM_LEFT , " " ) ;
this - > Interactor - > Render ( ) ;
}
@@ -218,33 +224,33 @@ void ActorDraggableInteractorStyle::OnMouseMove() {
int x = this - > Interactor - > GetEventPosition ( ) [ 0 ] ;
int y = this - > Interactor - > GetEventPosition ( ) [ 1 ] ;
switch ( this - > State ) {
case VTKIS_MEASURE :
MeasurePlace ( ) ;
//照抄源码, 不是很清楚这句话的作用, 可能有加速处理用户输入事件的作用( 连续InteractionEvent处理连续操作, 避免外部判断)
this - > InvokeEvent ( vtkCommand : : InteractionEvent , nullptr ) ;
break ;
case VTKIS_DRAG :
Drag ( ) ;
this - > InvokeEvent ( vtkCommand : : InteractionEvent , nullptr ) ;
break ;
case VTKIS_NONE :
NoneStatePick ( ) ;
this - > InvokeEvent ( vtkCommand : : InteractionEvent , nullptr ) ;
break ;
case VTKIS_COLORMAP :
this - > FindPokedRenderer ( x , y ) ;
this - > ColorMapping ( ) ;
this - > InvokeEvent ( vtkCommand : : InteractionEvent , nullptr ) ;
break ;
switch ( this - > State ) {
case VTKIS_MEASURE :
MeasurePlace ( ) ;
//照抄源码, 不是很清楚这句话的作用, 可能有加速处理用户输入事件的作用( 连续InteractionEvent处理连续操作, 避免外部判断)
this - > InvokeEvent ( vtkCommand : : InteractionEvent , nullptr ) ;
break ;
case VTKIS_DRAG :
Drag ( ) ;
this - > InvokeEvent ( vtkCommand : : InteractionEvent , nullptr ) ;
break ;
case VTKIS_NONE :
NoneStatePick ( ) ;
this - > InvokeEvent ( vtkCommand : : InteractionEvent , nullptr ) ;
break ;
case VTKIS_COLORMAP :
this - > FindPokedRenderer ( x , y ) ;
this - > ColorMapping ( ) ;
this - > InvokeEvent ( vtkCommand : : InteractionEvent , nullptr ) ;
break ;
}
vtkInteractorStyleImage : : OnMouseMove ( ) ;
}
vtkInteractorStyleImage : : OnMouseMove ( ) ;
}
void ActorDraggableInteractorStyle : : WindowLevel ( )
{
vtkRenderWindowInteractor * rwi = this - > Interactor ;
vtkRenderWindowInteractor * rwi = this - > Interactor ;
this - > WindowLevelCurrentPosition [ 0 ] = rwi - > GetEventPosition ( ) [ 0 ] ;
this - > WindowLevelCurrentPosition [ 1 ] = rwi - > GetEventPosition ( ) [ 1 ] ;
@@ -256,7 +262,7 @@ void ActorDraggableInteractorStyle::WindowLevel()
}
if ( this - > CurrentImageProperty )
{
int * size = this - > CurrentRenderer - > GetSize ( ) ;
int * size = this - > CurrentRenderer - > GetSize ( ) ;
double window = this - > WindowLevelInitial [ 0 ] ;
double level = this - > WindowLevelInitial [ 1 ] ;
@@ -315,7 +321,7 @@ void ActorDraggableInteractorStyle::WindowLevel()
}
}
void ActorDraggableInteractorStyle : : OnRightButtonDown ( )
void ActorDraggableInteractorStyle : : OnRightButtonDown ( )
{
int x = this - > Interactor - > GetEventPosition ( ) [ 0 ] ;
int y = this - > Interactor - > GetEventPosition ( ) [ 1 ] ;
@@ -332,58 +338,58 @@ void ActorDraggableInteractorStyle::OnRightButtonDown()
}
}
void ActorDraggableInteractorStyle : : OnLeftButtonDown ( ) {
int x = this - > Interactor - > GetEventPosition ( ) [ 0 ] ;
int y = this - > Interactor - > GetEventPosition ( ) [ 1 ] ;
int x = this - > Interactor - > GetEventPosition ( ) [ 0 ] ;
int y = this - > Interactor - > GetEventPosition ( ) [ 1 ] ;
this - > FindPokedRenderer ( x , y ) ;
if ( this - > CurrentRenderer = = nullptr )
{
return ;
}
// Redefine this button to handle window/level
this - > GrabFocus ( this - > EventCallbackCommand ) ;
this - > FindPokedRenderer ( x , y ) ;
if ( this - > CurrentRenderer = = nullptr )
{
return ;
}
// Redefine this button to handle window/level
this - > GrabFocus ( this - > EventCallbackCommand ) ;
if ( selectedProp ) {
selectedProp - > InvokeEvent ( DraggableActor : : DraggableActorEvents : : UnSelectedEvent ) ;
selectedProp = nullptr ;
}
if ( dragProp ) {
if ( dragProp ) {
selectedProp = dragProp ;
selectedProp - > InvokeEvent ( DraggableActor : : DraggableActorEvents : : SelectedEvent ) ;
if ( this - > Interactor - > GetRepeatCount ( ) )
if ( this - > Interactor - > GetRepeatCount ( ) )
{
dragProp - > InvokeEvent ( DraggableStyleEvents : : PopPropEvent , nullptr ) ;
}
DragStartOrigin [ 0 ] = x ;
DragStartOrigin [ 1 ] = y ;
this - > StartDrag ( ) ;
return ;
}
if ( Interactor - > GetRepeatCount ( ) ) {
if ( measure )
{
measure - > SetPlacing ( measure - > onMeasureDoubleClick ( this - > Interactor ) ) ;
if ( ! measure - > isMeasurePlacing ( ) ) {
this - > EndMeasure ( ) ;
auto temp = measure ;
measure = measure - > GetNextMeasure ( ) ;
if ( ! temp - > Valid ( ) ) {
temp - > ForceDelete ( ) ;
temp = nullptr ;
}
}
return ;
}
this - > InvokeEvent ( DraggableStyleEvents : : DoubleClickEvent , nullptr ) ;
return ;
}
if ( measure )
{
measure - > SetPlacing ( measure - > onMeasureLeftButtonDown ( this - > Interactor ) ) ;
if ( this - > State ! = VTKIS_MEASURE ) this - > StartMeasure ( ) ;
return ;
}
DragStartOrigin [ 0 ] = x ;
DragStartOrigin [ 1 ] = y ;
this - > StartDrag ( ) ;
return ;
}
if ( Interactor - > GetRepeatCount ( ) ) {
if ( measure )
{
measure - > SetPlacing ( measure - > onMeasureDoubleClick ( this - > Interactor ) ) ;
if ( ! measure - > isMeasurePlacing ( ) ) {
this - > EndMeasure ( ) ;
auto temp = measure ;
measure = measure - > GetNextMeasure ( ) ;
if ( ! temp - > Valid ( ) ) {
temp - > ForceDelete ( ) ;
temp = nullptr ;
}
}
return ;
}
this - > InvokeEvent ( DraggableStyleEvents : : DoubleClickEvent , nullptr ) ;
return ;
}
if ( measure )
{
measure - > SetPlacing ( measure - > onMeasureLeftButtonDown ( this - > Interactor ) ) ;
if ( this - > State ! = VTKIS_MEASURE ) this - > StartMeasure ( ) ;
return ;
}
if ( scalarProp )
if ( scalarProp )
{
ScalarStartPosition [ 0 ] = x ;
ScalarStartPosition [ 1 ] = y ;
@@ -392,207 +398,207 @@ void ActorDraggableInteractorStyle::OnLeftButtonDown() {
}
if ( this - > InteractionMode = = VTKIS_IMAGE_WINDOWLEVEL )
{
this - > WindowLevelStartPosition [ 0 ] = x ;
this - > WindowLevelStartPosition [ 1 ] = y ;
this - > StartWindowLevel ( ) ;
}
else if ( this - > InteractionMode = = VTKIS_IMAGE_ZOOM )
{
this - > DollyStartScale = this - > CurrentRenderer - > GetActiveCamera ( ) - > GetParallelScale ( ) ;
this - > StartDolly ( ) ;
}
else if ( this - > InteractionMode = = VTKIS_IMAGE_PAN )
{
this - > StartPan ( ) ;
}
else if ( this - > InteractionMode = = VTKIS_IMAGE_SLICING )
{
this - > StartSlice ( ) ;
}
if ( this - > InteractionMode = = VTKIS_IMAGE_WINDOWLEVEL )
{
this - > WindowLevelStartPosition [ 0 ] = x ;
this - > WindowLevelStartPosition [ 1 ] = y ;
this - > StartWindowLevel ( ) ;
}
else if ( this - > InteractionMode = = VTKIS_IMAGE_ZOOM )
{
this - > DollyStartScale = this - > CurrentRenderer - > GetActiveCamera ( ) - > GetParallelScale ( ) ;
this - > StartDolly ( ) ;
}
else if ( this - > InteractionMode = = VTKIS_IMAGE_PAN )
{
this - > StartPan ( ) ;
}
else if ( this - > InteractionMode = = VTKIS_IMAGE_SLICING )
{
this - > StartSlice ( ) ;
}
}
void ActorDraggableInteractorStyle : : ActiveMeasure ( Measure * m ) {
if ( this - > measure & & nullptr = = m ) {
this - > measure - > onTerminate ( this - > Interactor ) ;
}
this - > measure = m ;
void ActorDraggableInteractorStyle : : ActiveMeasure ( Measure * m ) {
if ( this - > measure & & nullptr = = m ) {
this - > measure - > onTerminate ( this - > Interactor ) ;
}
this - > measure = m ;
}
void ActorDraggableInteractorStyle : : UnActiveMeasure ( ) {
if ( this - > measure ) {
this - > measure - > onTerminate ( this - > Interactor ) ;
}
this - > EndMeasure ( ) ;
this - > measure = nullptr ;
if ( this - > measure ) {
this - > measure - > onTerminate ( this - > Interactor ) ;
}
this - > EndMeasure ( ) ;
this - > measure = nullptr ;
}
void ActorDraggableInteractorStyle : : DispatchEvent ( ) {
switch ( this - > State ) {
case VTKIS_SLICE :
switch ( this - > State ) {
case VTKIS_SLICE :
if ( this - > HandleObservers ) {
//double check
if ( ! this - > CurrentImageSlice ) {
this - > SetCurrentImageNumber ( this - > CurrentImageNumber ) ;
}
if ( ! this - > CurrentImageSlice ) return ;
vtkImageSliceMapper * mapper = vtkImageSliceMapper : : SafeDownCast ( this - > CurrentImageSlice - > GetMapper ( ) ) ;
int slice [ 1 ] = { mapper ? mapper - > GetSliceNumber ( ) : - 1 } ;
//鼠标滑动不一定能造成翻页!!!所以需要进行一次判定
if ( slice [ 0 ] ! = lastslice ) {
this - > InvokeEvent ( DraggableStyleEvents : : SlicedEvent , slice ) ;
lastslice = slice [ 0 ] ;
}
break ;
}
}
if ( this - > HandleObservers ) {
//double check
if ( ! this - > CurrentImageSlice ) {
this - > SetCurrentImageNumber ( this - > CurrentImageNumber ) ;
}
if ( ! this - > CurrentImageSlice ) return ;
vtkImageSliceMapper * mapper = vtkImageSliceMapper : : SafeDownCast ( this - > CurrentImageSlice - > GetMapper ( ) ) ;
int slice [ 1 ] = { mapper ? mapper - > GetSliceNumber ( ) : - 1 } ;
//鼠标滑动不一定能造成翻页!!!所以需要进行一次判定
if ( slice [ 0 ] ! = lastslice ) {
this - > InvokeEvent ( DraggableStyleEvents : : SlicedEvent , slice ) ;
lastslice = slice [ 0 ] ;
}
break ;
}
}
}
//重写部分逻辑, 在取imageProperty的时候把ImageSlice也取了。
void ActorDraggableInteractorStyle : : SetCurrentImageNumber ( int i )
{
this - > CurrentImageNumber = i ;
if ( ! this - > CurrentRenderer )
{
return ;
}
vtkPropCollection * props = this - > CurrentRenderer - > GetViewProps ( ) ;
vtkProp * prop = nullptr ;
vtkAssemblyPath * path ;
vtkImageSlice * imageProp = nullptr ;
vtkCollectionSimpleIterator pit ;
this - > CurrentImageNumber = i ;
if ( ! this - > CurrentRenderer )
{
return ;
}
vtkPropCollection * props = this - > CurrentRenderer - > GetViewProps ( ) ;
vtkProp * prop = nullptr ;
vtkAssemblyPath * path ;
vtkImageSlice * imageProp = nullptr ;
vtkCollectionSimpleIterator pit ;
for ( int k = 0 ; k < 2 ; k + + )
{
int j = 0 ;
for ( props - > InitTraversal ( pit ) ; ( prop = props - > GetNextProp ( pit ) ) ; )
{
bool foundImageProp = false ;
for ( prop - > InitPathTraversal ( ) ; ( path = prop - > GetNextPath ( ) ) ; )
{
vtkProp * tryProp = path - > GetLastNode ( ) - > GetViewProp ( ) ;
imageProp = vtkImageSlice : : SafeDownCast ( tryProp ) ;
if ( imageProp )
{
if ( j = = i & & imageProp - > GetPickable ( ) )
{
foundImageProp = true ;
break ;
}
imageProp = nullptr ;
j + + ;
}
}
if ( foundImageProp )
{
break ;
}
}
if ( i < 0 )
{
i + = j ;
}
}
for ( int k = 0 ; k < 2 ; k + + )
{
int j = 0 ;
for ( props - > InitTraversal ( pit ) ; ( prop = props - > GetNextProp ( pit ) ) ; )
{
bool foundImageProp = false ;
for ( prop - > InitPathTraversal ( ) ; ( path = prop - > GetNextPath ( ) ) ; )
{
vtkProp * tryProp = path - > GetLastNode ( ) - > GetViewProp ( ) ;
imageProp = vtkImageSlice : : SafeDownCast ( tryProp ) ;
if ( imageProp )
{
if ( j = = i & & imageProp - > GetPickable ( ) )
{
foundImageProp = true ;
break ;
}
imageProp = nullptr ;
j + + ;
}
}
if ( foundImageProp )
{
break ;
}
}
if ( i < 0 )
{
i + = j ;
}
}
vtkImageProperty * property = nullptr ;
if ( imageProp )
{
property = imageProp - > GetProperty ( ) ;
if ( imageProp ! = this - > CurrentImageSlice )
{
if ( this - > CurrentImageSlice )
{
this - > CurrentImageSlice - > Delete ( ) ;
}
vtkImageProperty * property = nullptr ;
if ( imageProp )
{
property = imageProp - > GetProperty ( ) ;
if ( imageProp ! = this - > CurrentImageSlice )
{
if ( this - > CurrentImageSlice )
{
this - > CurrentImageSlice - > Delete ( ) ;
}
this - > CurrentImageSlice = imageProp ;
this - > CurrentImageSlice = imageProp ;
if ( this - > CurrentImageSlice )
{
this - > CurrentImageSlice - > Register ( this ) ;
}
}
}
if ( this - > CurrentImageSlice )
{
this - > CurrentImageSlice - > Register ( this ) ;
}
}
}
if ( property ! = this - > CurrentImageProperty )
{
if ( this - > CurrentImageProperty )
{
this - > CurrentImageProperty - > Delete ( ) ;
}
if ( property ! = this - > CurrentImageProperty )
{
if ( this - > CurrentImageProperty )
{
this - > CurrentImageProperty - > Delete ( ) ;
}
this - > CurrentImageProperty = property ;
this - > CurrentImageProperty = property ;
if ( this - > CurrentImageProperty )
{
this - > CurrentImageProperty - > Register ( this ) ;
}
}
if ( this - > CurrentImageProperty )
{
this - > CurrentImageProperty - > Register ( this ) ;
}
}
}
void ActorDraggableInteractorStyle : : EndDolly ( ) {
if ( this - > State ! = VTKIS_DOLLY )
{
return ;
}
this - > StopState ( ) ;
if ( this - > CurrentRenderer = = nullptr )
{
return ;
}
//激发缩放完成事件
if ( this - > HandleObservers ) {
vtkCamera * camera = this - > CurrentRenderer - > GetActiveCamera ( ) ;
double result [ 2 ] = { 0.0 , 0.0 } ;
//image 必然是ParallelProjection
result [ 0 ] = this - > DollyStartScale ;
result [ 1 ] = camera - > GetParallelScale ( ) ;
this - > InvokeEvent ( DraggableStyleEvents : : EndDollyEvent , result ) ;
}
if ( this - > State ! = VTKIS_DOLLY )
{
return ;
}
this - > StopState ( ) ;
if ( this - > CurrentRenderer = = nullptr )
{
return ;
}
//激发缩放完成事件
if ( this - > HandleObservers ) {
vtkCamera * camera = this - > CurrentRenderer - > GetActiveCamera ( ) ;
double result [ 2 ] = { 0.0 , 0.0 } ;
//image 必然是ParallelProjection
result [ 0 ] = this - > DollyStartScale ;
result [ 1 ] = camera - > GetParallelScale ( ) ;
this - > InvokeEvent ( DraggableStyleEvents : : EndDollyEvent , result ) ;
}
}
void ActorDraggableInteractorStyle : : StartPan ( ) {
vtkInteractorStyle : : StartPan ( ) ;
vtkCamera * camera = this - > CurrentRenderer - > GetActiveCamera ( ) ;
camera - > GetFocalPoint ( PanStartOrigin ) ;
vtkInteractorStyle : : StartPan ( ) ;
vtkCamera * camera = this - > CurrentRenderer - > GetActiveCamera ( ) ;
camera - > GetFocalPoint ( PanStartOrigin ) ;
}
void ActorDraggableInteractorStyle : : EndPan ( ) {
if ( this - > State ! = VTKIS_PAN ) return ;
if ( this - > HandleObservers ) {
vtkCamera * camera = this - > CurrentRenderer - > GetActiveCamera ( ) ;
double * nf = camera - > GetFocalPoint ( ) ;
double calldata [ 6 ] = { PanStartOrigin [ 0 ] , PanStartOrigin [ 1 ] , PanStartOrigin [ 2 ] , nf [ 0 ] , nf [ 1 ] , nf [ 2 ] } ;
this - > InvokeEvent ( vtkCommand : : EventIds : : EndPanEvent , calldata ) ;
}
this - > StopState ( ) ;
if ( this - > State ! = VTKIS_PAN ) return ;
if ( this - > HandleObservers ) {
vtkCamera * camera = this - > CurrentRenderer - > GetActiveCamera ( ) ;
double * nf = camera - > GetFocalPoint ( ) ;
double calldata [ 6 ] = { PanStartOrigin [ 0 ] , PanStartOrigin [ 1 ] , PanStartOrigin [ 2 ] , nf [ 0 ] , nf [ 1 ] , nf [ 2 ] } ;
this - > InvokeEvent ( vtkCommand : : EventIds : : EndPanEvent , calldata ) ;
}
this - > StopState ( ) ;
}
void ActorDraggableInteractorStyle : : EndWindowLevel ( ) {
if ( this - > State ! = VTKIS_WINDOW_LEVEL ) {
return ;
}
if ( this - > HandleObservers ) {
double calldata [ 2 ] = { this - > CurrentImageProperty - > GetColorWindow ( ) , this - > CurrentImageProperty - > GetColorLevel ( ) } ;
this - > InvokeEvent ( vtkCommand : : EndWindowLevelEvent , calldata ) ;
}
this - > StopState ( ) ;
if ( this - > State ! = VTKIS_WINDOW_LEVEL ) {
return ;
}
if ( this - > HandleObservers ) {
double calldata [ 2 ] = { this - > CurrentImageProperty - > GetColorWindow ( ) , this - > CurrentImageProperty - > GetColorLevel ( ) } ;
this - > InvokeEvent ( vtkCommand : : EndWindowLevelEvent , calldata ) ;
}
this - > StopState ( ) ;
}
void ActorDraggableInteractorStyle : : OnChar ( ) {
vtkInteractorStyleImage : : OnChar ( ) ;
vtkRenderWindowInteractor * rwi = this - > Interactor ;
vtkInteractorStyleImage : : OnChar ( ) ;
vtkRenderWindowInteractor * rwi = this - > Interactor ;
std : : string keySym = rwi - > GetKeySym ( ) ;
if ( keySym = = " Delete " )
{
if ( selectedProp )
{
this - > InvokeEvent ( DraggableStyleEvents : : DeleteMeasureEvent , selectedProp ) ;
}
}
if ( keySym = = " Delete " )
{
if ( selectedProp )
{
this - > InvokeEvent ( DraggableStyleEvents : : DeleteMeasureEvent , selectedProp ) ;
}
}
}