Volume measure preparing1.
This commit is contained in:
@@ -14,18 +14,22 @@
|
|||||||
#include <vtkPropCollection.h>
|
#include <vtkPropCollection.h>
|
||||||
#include <vtkAssemblyPath.h>
|
#include <vtkAssemblyPath.h>
|
||||||
#include <vtkVolumeProperty.h>
|
#include <vtkVolumeProperty.h>
|
||||||
|
#include <vtkPropPicker.h>
|
||||||
#include <vtkPiecewiseFunction.h>
|
#include <vtkPiecewiseFunction.h>
|
||||||
|
|
||||||
|
#include "Rendering/Core/DraggableActor.h"
|
||||||
|
|
||||||
vtkStandardNewMacro(VolumeInteractorStyle)
|
vtkStandardNewMacro(VolumeInteractorStyle)
|
||||||
|
|
||||||
VolumeInteractorStyle::VolumeInteractorStyle():vtkInteractorStyleTrackballCamera()
|
VolumeInteractorStyle::VolumeInteractorStyle():vtkInteractorStyleTrackballCamera()
|
||||||
,InteractionMode(VOLUME_ROTATE3D)
|
,InteractionMode(VTKIS_VOLUME_ROTATE3D)
|
||||||
|
,picker(vtkPropPicker::New())
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VolumeInteractorStyle::~VolumeInteractorStyle() {
|
VolumeInteractorStyle::~VolumeInteractorStyle() {
|
||||||
|
picker->Delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VolumeInteractorStyle::OnLeftButtonDown() {
|
void VolumeInteractorStyle::OnLeftButtonDown() {
|
||||||
@@ -38,6 +42,36 @@ void VolumeInteractorStyle::OnLeftButtonDown() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->GrabFocus(this->EventCallbackCommand);
|
this->GrabFocus(this->EventCallbackCommand);
|
||||||
|
if (selectedProp) {
|
||||||
|
selectedProp->InvokeEvent(DraggableActor::DraggableActorEvents::UnSelectedEvent);
|
||||||
|
selectedProp = nullptr;
|
||||||
|
}
|
||||||
|
if (dragProp) {
|
||||||
|
selectedProp = dragProp;
|
||||||
|
selectedProp->InvokeEvent(DraggableActor::DraggableActorEvents::SelectedEvent);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
switch(this->InteractionMode) {
|
switch(this->InteractionMode) {
|
||||||
case VTKIS_VOLUME_ROTATE3D: {
|
case VTKIS_VOLUME_ROTATE3D: {
|
||||||
this->StartRotate();
|
this->StartRotate();
|
||||||
@@ -122,7 +156,8 @@ void VolumeInteractorStyle::OnMouseMove() {
|
|||||||
this->InvokeEvent(vtkCommand::InteractionEvent, nullptr);
|
this->InvokeEvent(vtkCommand::InteractionEvent, nullptr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
this->Superclass::OnMouseMove();
|
vtkInteractorStyleTrackballCamera::OnMouseMove();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VolumeInteractorStyle::WindowLevel() {
|
void VolumeInteractorStyle::WindowLevel() {
|
||||||
@@ -201,7 +236,7 @@ void VolumeInteractorStyle::GetCurrentVolumeProperty() {
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (VolumeProperty)return;
|
||||||
vtkPropCollection *props = this->CurrentRenderer->GetViewProps();
|
vtkPropCollection *props = this->CurrentRenderer->GetViewProps();
|
||||||
vtkProp *prop = nullptr;
|
vtkProp *prop = nullptr;
|
||||||
vtkAssemblyPath *path;
|
vtkAssemblyPath *path;
|
||||||
@@ -218,15 +253,9 @@ void VolumeInteractorStyle::GetCurrentVolumeProperty() {
|
|||||||
{
|
{
|
||||||
vtkProp *tryProp = path->GetLastNode()->GetViewProp();
|
vtkProp *tryProp = path->GetLastNode()->GetViewProp();
|
||||||
volumeProp = vtkVolume::SafeDownCast(tryProp);
|
volumeProp = vtkVolume::SafeDownCast(tryProp);
|
||||||
if (volumeProp)
|
if (volumeProp) {
|
||||||
{
|
foundImageProp = true;
|
||||||
if (volumeProp->GetPickable())
|
break;
|
||||||
{
|
|
||||||
foundImageProp = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
volumeProp = nullptr;
|
|
||||||
j++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (foundImageProp)
|
if (foundImageProp)
|
||||||
@@ -251,3 +280,10 @@ void VolumeInteractorStyle::GetCurrentVolumeProperty() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VolumeInteractorStyle::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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,11 @@
|
|||||||
#include "Rendering/Core/RenderingDefines.h"
|
#include "Rendering/Core/RenderingDefines.h"
|
||||||
|
|
||||||
class vtkVolumeProperty;
|
class vtkVolumeProperty;
|
||||||
|
class vtkPropPicker;
|
||||||
|
class vtkProp;
|
||||||
|
class Measure;
|
||||||
|
|
||||||
|
#include <vtkRenderer.h>
|
||||||
|
|
||||||
class VolumeInteractorStyle:public vtkInteractorStyleTrackballCamera {
|
class VolumeInteractorStyle:public vtkInteractorStyleTrackballCamera {
|
||||||
public:
|
public:
|
||||||
@@ -16,9 +21,11 @@ public:
|
|||||||
|
|
||||||
vtkTypeMacro(VolumeInteractorStyle, vtkInteractorStyleTrackballCamera);
|
vtkTypeMacro(VolumeInteractorStyle, vtkInteractorStyleTrackballCamera);
|
||||||
|
|
||||||
vtkSetClampMacro(InteractionMode, int, VOLUME_ROTATE3D, VOLUME_WINDOW);
|
vtkSetClampMacro(InteractionMode, int, VTKIS_VOLUME_ROTATE3D, VTKIS_VOLUME_WINDOW);
|
||||||
vtkGetMacro(InteractionMode, int);
|
vtkGetMacro(InteractionMode, int);
|
||||||
|
|
||||||
|
// vtkSetObjectMacro(MainRenderer,vtkRenderer)
|
||||||
|
|
||||||
virtual void StartWindowLevel();
|
virtual void StartWindowLevel();
|
||||||
virtual void EndWindowLevel();
|
virtual void EndWindowLevel();
|
||||||
void OnLeftButtonDown() override;
|
void OnLeftButtonDown() override;
|
||||||
@@ -37,6 +44,30 @@ protected:
|
|||||||
|
|
||||||
~VolumeInteractorStyle() override;
|
~VolumeInteractorStyle() override;
|
||||||
|
|
||||||
|
void StartDrag() {
|
||||||
|
this->StartState(VTKIS_DRAG);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EndDrag() {
|
||||||
|
if (this->State != VTKIS_DRAG) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this->StopState();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Drag();
|
||||||
|
|
||||||
|
void StartMeasure() {
|
||||||
|
this->StartState(VTKIS_MEASURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EndMeasure() {
|
||||||
|
if (this->State != VTKIS_MEASURE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this->StopState();
|
||||||
|
this->InvokeEvent(EndMeasureEvent, this->measure);
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
VolumeInteractorStyle(const VolumeInteractorStyle &) = delete;
|
VolumeInteractorStyle(const VolumeInteractorStyle &) = delete;
|
||||||
|
|
||||||
@@ -47,7 +78,12 @@ private:
|
|||||||
int InteractionMode;
|
int InteractionMode;
|
||||||
|
|
||||||
vtkVolumeProperty* VolumeProperty = nullptr;
|
vtkVolumeProperty* VolumeProperty = nullptr;
|
||||||
|
vtkPropPicker* picker;
|
||||||
|
vtkProp *dragProp = nullptr;
|
||||||
|
vtkProp *selectedProp = nullptr;
|
||||||
|
Measure *measure = nullptr;
|
||||||
|
vtkRenderer* MainRenderer;
|
||||||
|
int DragStartOrigin[2] = {0, 0};
|
||||||
double WindowLevelInitial[2] = {0.0, 0.0};
|
double WindowLevelInitial[2] = {0.0, 0.0};
|
||||||
double WindowLevelStartPosition[2] = {0.0, 0.0};
|
double WindowLevelStartPosition[2] = {0.0, 0.0};
|
||||||
double WindowLevelCurrentPosition[2] = {0.0, 0.0};
|
double WindowLevelCurrentPosition[2] = {0.0, 0.0};
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ VolumeRenderingViewer::VolumeRenderingViewer()
|
|||||||
volumeProperty->SetSpecular(0.2);
|
volumeProperty->SetSpecular(0.2);
|
||||||
volumeProperty->SetSpecularPower(10.0);
|
volumeProperty->SetSpecularPower(10.0);
|
||||||
VolumeActor->SetProperty(volumeProperty);
|
VolumeActor->SetProperty(volumeProperty);
|
||||||
|
VolumeActor->SetPickable(false);
|
||||||
VolumeActor->SetMapper(VolumeMapper);
|
VolumeActor->SetMapper(VolumeMapper);
|
||||||
vtkNew<vtkTextProperty> prop;
|
vtkNew<vtkTextProperty> prop;
|
||||||
prop->SetFontFamilyToArial();
|
prop->SetFontFamilyToArial();
|
||||||
|
|||||||
Reference in New Issue
Block a user