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