Format ActorDraggableInteractorStyle

This commit is contained in:
Krad
2022-06-29 14:09:15 +08:00
parent 21958db474
commit d9e53284ad
2 changed files with 683 additions and 738 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -24,216 +24,229 @@
class vtkProp; class vtkProp;
class Measure; class Measure;
class vtkImageSlice; class vtkImageSlice;
class ActorDraggableInteractorStyle : public vtkInteractorStyleImage { class ActorDraggableInteractorStyle : public vtkInteractorStyleImage {
public: public:
static ActorDraggableInteractorStyle* New(); static ActorDraggableInteractorStyle *New();
vtkTypeMacro(ActorDraggableInteractorStyle, vtkInteractorStyleImage);
enum DraggableStyleEvents vtkTypeMacro(ActorDraggableInteractorStyle, vtkInteractorStyleImage);
{
DragEvent = vtkCommand::UserEvent + 300,
DragEndEvent,
StartMeasureEvent,
EndMeasureEvent,
SliceEvent,
SlicedEvent,
EndDollyEvent,
PopPropEvent,
DoubleClickEvent,
DeleteMeasureEvent,
RightButtonClickEvent,
ScalarOpacityEvent,
ScalarShiftEvent,
AfterViewerClicked
};
/** enum DraggableStyleEvents {
* Called when the user moves the mouse DragEvent = vtkCommand::UserEvent + 300,
* Default behavior forwards the event to the observed scene. DragEndEvent,
*/ StartMeasureEvent,
void OnMouseMove() override; EndMeasureEvent,
SliceEvent,
SlicedEvent,
EndDollyEvent,
PopPropEvent,
DoubleClickEvent,
DeleteMeasureEvent,
RightButtonClickEvent,
ScalarOpacityEvent,
ScalarShiftEvent,
AfterViewerClicked
};
/** /**
* Called when the user clicks the mouse left button. * Called when the user moves the mouse
* Default behavior forwards the event to the observed scene. * Default behavior forwards the event to the observed scene.
*/ */
void OnRightButtonDown() override; void OnMouseMove() override;
void OnLeftButtonDown() override;
/** /**
* Called when the user releases the mouse left button. * Called when the user clicks the mouse left button.
* Default behavior forwards the event to the observed scene. * Default behavior forwards the event to the observed scene.
*/ */
void OnLeftButtonUp() override; void OnRightButtonDown() override;
void OnMouseWheelForward() override{} void OnLeftButtonDown() override;
void OnMouseWheelBackward() override{}
void OnChar() override; /**
void EndDolly() override; * Called when the user releases the mouse left button.
* Default behavior forwards the event to the observed scene.
*/
void OnLeftButtonUp() override;
void OnMouseWheelForward() override {}
void OnMouseWheelBackward() override {}
void OnChar() override;
void EndDolly() override;
void WindowLevel() override; void WindowLevel() override;
void Slice() override; void Slice() override;
void SetCurrentImageNumber(int i) override; void SetCurrentImageNumber(int i) override;
vtkSetClampMacro(InteractionMode, int, VTKIS_IMAGE2D, VTKIS_IMAGE_WINDOWLEVEL); void SetInteractionModeFromEnum(int InteractionMode) {
void SetInteractionModeToImage2D() {} this->UnActiveMeasure();
void SetInteractionModeToImage3D() {} this->SetInteractionMode(InteractionMode);
}
void SetInteractionModeFromEnum(int InteractionMode) //void SetInteractionModeToImageSlicing() {
{ // this->UnActiveMeasure();
this->UnActiveMeasure(); // this->SetInteractionMode(VTKIS_IMAGE_SLICING);
this->SetInteractionMode(InteractionMode); //}
} //void SetInteractionModeToImagePan(){
// this->UnActiveMeasure();
//void SetInteractionModeToImageSlicing() { // this->SetInteractionMode(VTKIS_IMAGE_PAN);
// this->UnActiveMeasure(); //}
// this->SetInteractionMode(VTKIS_IMAGE_SLICING); //void SetInteractionModeToImageWindowLevel(){
//} // this->UnActiveMeasure();
//void SetInteractionModeToImagePan(){ // this->SetInteractionMode(VTKIS_IMAGE_WINDOWLEVEL);
// this->UnActiveMeasure(); //}
// this->SetInteractionMode(VTKIS_IMAGE_PAN); //void SetInteractionModeToImageZoom(){
//} // this->UnActiveMeasure();
//void SetInteractionModeToImageWindowLevel(){ // this->SetInteractionMode(VTKIS_IMAGE_ZOOM);
// this->UnActiveMeasure(); //}
// this->SetInteractionMode(VTKIS_IMAGE_WINDOWLEVEL);
//}
//void SetInteractionModeToImageZoom(){
// this->UnActiveMeasure();
// this->SetInteractionMode(VTKIS_IMAGE_ZOOM);
//}
vtkSetObjectMacro(CornerAnnotation, vtkCornerAnnotation); vtkSetObjectMacro(CornerAnnotation, vtkCornerAnnotation);
vtkProp* GetSelectedProp() vtkProp *GetSelectedProp() {
{ return selectedProp;
return selectedProp; }
}
void ClearSelectedProp() {
if (dragProp == selectedProp) dragProp = nullptr;
selectedProp = nullptr;
}
void ActiveMeasure(Measure* m);
void UnActiveMeasure();
void SetCurrentImageSlice(vtkImageSlice* slice){ void ClearSelectedProp() {
CurrentImageSlice = slice; if (dragProp == selectedProp) dragProp = nullptr;
CurrentImageProperty = slice->GetProperty(); selectedProp = nullptr;
} }
void ActiveMeasure(Measure *m);
void UnActiveMeasure();
void SetCurrentImageSlice(vtkImageSlice *slice) {
CurrentImageSlice = slice;
CurrentImageProperty = slice->GetProperty();
}
protected: protected:
ActorDraggableInteractorStyle(); ActorDraggableInteractorStyle();
~ActorDraggableInteractorStyle() override;
void StartDrag() { ~ActorDraggableInteractorStyle() override;
this->StartState(VTKIS_DRAG);
} void StartDrag() {
void EndDrag() { this->StartState(VTKIS_DRAG);
if (this->State != VTKIS_DRAG) }
{
return; void EndDrag() {
} if (this->State != VTKIS_DRAG) {
this->StopState(); return;
} }
void Drag(); this->StopState();
}
void Drag();
void StartColorMapping() void StartColorMapping() {
{ OpacityTrigger = false;
OpacityTrigger = false; ConsumedOpacity = 0;
ConsumedOpacity = 0; this->StartState(VTKIS_COLORMAP);
this->StartState(VTKIS_COLORMAP); }
}
void EndColorMapping(); void EndColorMapping();
void ColorMapping();
bool OpacityTrigger = false;
void StartMeasure() { void ColorMapping();
this->StartState(VTKIS_MEASURE);
} bool OpacityTrigger = false;
void EndMeasure() {
if (this->State != VTKIS_MEASURE) void StartMeasure() {
{ this->StartState(VTKIS_MEASURE);
return; }
}
this->StopState(); void EndMeasure() {
this->InvokeEvent(EndMeasureEvent, this->measure); if (this->State != VTKIS_MEASURE) {
} return;
void StartPan() override; }
void EndPan() override; this->StopState();
void EndWindowLevel() override; this->InvokeEvent(EndMeasureEvent, this->measure);
void MeasurePlace(); }
void NoneStatePick();
void DispatchEvent(); void StartPan() override;
void EndPan() override;
void EndWindowLevel() override;
void MeasurePlace();
void NoneStatePick();
void DispatchEvent();
private: private:
ActorDraggableInteractorStyle(const ActorDraggableInteractorStyle&) = delete; ActorDraggableInteractorStyle(const ActorDraggableInteractorStyle &) = delete;
void operator=(const ActorDraggableInteractorStyle&) = delete;
vtkNew<vtkPropPicker> picker;
vtkProp* scalarProp = nullptr; void operator=(const ActorDraggableInteractorStyle &) = delete;
vtkProp* dragProp = nullptr;
vtkProp* selectedProp = nullptr;
int DragStartOrigin[2] = { 0, 0 };
vtkCornerAnnotation * CornerAnnotation = nullptr;
//bool isCornderAnno = true;
Measure* measure = nullptr;
double PanStartOrigin[3] = { 0.0, 0.0, 0.0 };
double DollyStartScale = 1.0;
vtkImageSlice * CurrentImageSlice = nullptr;
int lastslice = -1;
int ScalarStartPosition[2] = { 0, 0 }; vtkNew<vtkPropPicker> picker;
int ScalarCurrentPosition[2] = { 0, 0 };
double ConsumedOpacity = 0;
void TestOutPut(vtkObject*, unsigned long eventid, void* calldata) { vtkProp *scalarProp = nullptr;
switch (eventid) { vtkProp *dragProp = nullptr;
case DraggableStyleEvents::SlicedEvent: vtkProp *selectedProp = nullptr;
{ int DragStartOrigin[2] = {0, 0};
int* r = (int*)calldata; vtkCornerAnnotation *CornerAnnotation = nullptr;
//bool isCornderAnno = true;
Measure *measure = nullptr;
double PanStartOrigin[3] = {0.0, 0.0, 0.0};
double DollyStartScale = 1.0;
vtkImageSlice *CurrentImageSlice = nullptr;
int lastslice = -1;
printf("Sliced, current slice number:%d \r\n", r[0]); int ScalarStartPosition[2] = {0, 0};
int ScalarCurrentPosition[2] = {0, 0};
double ConsumedOpacity = 0;
break; void TestOutPut(vtkObject *, unsigned long eventid, void *calldata) {
} switch (eventid) {
case DraggableStyleEvents::EndDollyEvent: { case DraggableStyleEvents::SlicedEvent: {
double *d = (double *)calldata; int *r = (int *) calldata;
printf("EndDolly, scale param:%f,%f \r\n", d[0], d[1]); printf("Sliced, current slice number:%d \r\n", r[0]);
break; break;
} }
case vtkCommand::EventIds::EndPanEvent: { case DraggableStyleEvents::EndDollyEvent: {
double *d = (double *)calldata; double *d = (double *) calldata;
printf("EndPan, last focalpoint:%f,%f,%f;current focalpoint:%f,%f,%f \r\n", d[0], d[1], d[2], d[3], printf("EndDolly, scale param:%f,%f \r\n", d[0], d[1]);
d[4], d[5]);
break; break;
} }
case vtkCommand::EventIds::EndWindowLevelEvent: case vtkCommand::EventIds::EndPanEvent: {
{ double *d = (double *) calldata;
double *d = (double *)calldata;
printf("EndWindowLevel, scale param:%f,%f \r\n", d[0], d[1]); printf("EndPan, last focalpoint:%f,%f,%f;current focalpoint:%f,%f,%f \r\n", d[0], d[1], d[2], d[3],
d[4], d[5]);
break; break;
} }
default: case vtkCommand::EventIds::EndWindowLevelEvent: {
double *d = (double *) calldata;
printf("current event :%s", vtkCommand::GetStringFromEventId(eventid)); printf("EndWindowLevel, scale param:%f,%f \r\n", d[0], d[1]);
break;
} break;
} }
default:
printf("current event :%s", vtkCommand::GetStringFromEventId(eventid));
break;
}
}
}; };
#endif //OMEGAV_ACTORDRAGGABLEINTERACTORSTYLE_H #endif //OMEGAV_ACTORDRAGGABLEINTERACTORSTYLE_H