Corner annotation render logic.
This commit is contained in:
@@ -168,8 +168,8 @@ void VolumeInteractorStyle::OnMouseMove() {
|
||||
// this->InvokeEvent(vtkCommand::InteractionEvent, nullptr);
|
||||
break;
|
||||
case VTKIS_ROTATE:
|
||||
case VTKIS_PAN:
|
||||
case VTKIS_SPIN:
|
||||
case VTKIS_PAN:
|
||||
case VTKIS_DOLLY:
|
||||
this->CurrentRenderer->GetActiveCamera()->Modified();
|
||||
break;
|
||||
@@ -200,7 +200,6 @@ void VolumeInteractorStyle::OnMouseMove() {
|
||||
}
|
||||
}
|
||||
vtkInteractorStyleTrackballCamera::OnMouseMove();
|
||||
|
||||
}
|
||||
|
||||
void VolumeInteractorStyle::WindowLevel() {
|
||||
@@ -209,12 +208,7 @@ void VolumeInteractorStyle::WindowLevel() {
|
||||
this->WindowLevelCurrentPosition[0] = rwi->GetEventPosition()[0];
|
||||
this->WindowLevelCurrentPosition[1] = rwi->GetEventPosition()[1];
|
||||
|
||||
if (this->HandleObservers &&
|
||||
this->HasObserver(vtkCommand::WindowLevelEvent))
|
||||
{
|
||||
this->InvokeEvent(vtkCommand::WindowLevelEvent, this);
|
||||
}
|
||||
else if(VolumeProperty){
|
||||
if(VolumeProperty){
|
||||
auto opacity = VolumeProperty->GetScalarOpacity();
|
||||
if (opacity) {
|
||||
double range[2] = {0.0, 0.0};
|
||||
@@ -270,6 +264,7 @@ void VolumeInteractorStyle::WindowLevel() {
|
||||
opacity->AddPoint(newMin,0.0);
|
||||
opacity->AddPoint(newMax,1.0);
|
||||
VolumeProperty->Modified();
|
||||
this->InvokeEvent(vtkCommand::WindowLevelEvent, this);
|
||||
this->Interactor->Render();
|
||||
}
|
||||
}
|
||||
@@ -376,3 +371,60 @@ void VolumeInteractorStyle::EndMeasure() {
|
||||
this->InvokeEvent(EndMeasureEvent, this->measure);
|
||||
}
|
||||
|
||||
void VolumeInteractorStyle::Rotate() {
|
||||
if (this->CurrentRenderer == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
vtkRenderWindowInteractor *rwi = this->Interactor;
|
||||
|
||||
int dx = rwi->GetEventPosition()[0] - rwi->GetLastEventPosition()[0];
|
||||
int dy = rwi->GetEventPosition()[1] - rwi->GetLastEventPosition()[1];
|
||||
|
||||
const int *size = this->CurrentRenderer->GetRenderWindow()->GetSize();
|
||||
|
||||
double delta_elevation = -20.0 / size[1];
|
||||
double delta_azimuth = -20.0 / size[0];
|
||||
|
||||
double rxf = dx * delta_azimuth * this->MotionFactor;
|
||||
double ryf = dy * delta_elevation * this->MotionFactor;
|
||||
|
||||
vtkCamera *camera = this->CurrentRenderer->GetActiveCamera();
|
||||
camera->Azimuth(rxf);
|
||||
camera->Elevation(ryf);
|
||||
camera->OrthogonalizeViewUp();
|
||||
|
||||
if (this->AutoAdjustCameraClippingRange) {
|
||||
this->CurrentRenderer->ResetCameraClippingRange();
|
||||
}
|
||||
|
||||
if (rwi->GetLightFollowCamera()) {
|
||||
this->CurrentRenderer->UpdateLightsGeometryToFollowCamera();
|
||||
}
|
||||
this->InvokeEvent(vtkCommand::RotateEvent);
|
||||
rwi->Render();
|
||||
}
|
||||
|
||||
void VolumeInteractorStyle::Spin() {
|
||||
if (this->CurrentRenderer == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vtkRenderWindowInteractor* rwi = this->Interactor;
|
||||
|
||||
double* center = this->CurrentRenderer->GetCenter();
|
||||
|
||||
double newAngle = vtkMath::DegreesFromRadians(
|
||||
atan2(rwi->GetEventPosition()[1] - center[1], rwi->GetEventPosition()[0] - center[0]));
|
||||
|
||||
double oldAngle = vtkMath::DegreesFromRadians(
|
||||
atan2(rwi->GetLastEventPosition()[1] - center[1], rwi->GetLastEventPosition()[0] - center[0]));
|
||||
|
||||
vtkCamera* camera = this->CurrentRenderer->GetActiveCamera();
|
||||
camera->Roll(newAngle - oldAngle);
|
||||
camera->OrthogonalizeViewUp();
|
||||
this->InvokeEvent(vtkCommand::RotateEvent);
|
||||
rwi->Render();
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,10 @@ protected:
|
||||
void EndMeasure();
|
||||
|
||||
void MeasurePlace();
|
||||
|
||||
void Rotate() override;
|
||||
void Spin() override;
|
||||
|
||||
private:
|
||||
VolumeInteractorStyle(const VolumeInteractorStyle &) = delete;
|
||||
|
||||
|
||||
@@ -193,6 +193,8 @@ void VolumeRenderingViewer::InstallPipeline() {
|
||||
&VolumeRenderingViewer::DecreaseMaximumImageSampleDistance);
|
||||
this->InteractorStyle->AddObserver(vtkCommand::EndWindowLevelEvent,this,
|
||||
&VolumeRenderingViewer::ResetMaximumImageSampleDistance);
|
||||
InteractorStyle->AddObserver(vtkCommand::RotateEvent,this, &VolumeRenderingViewer::renderOrientationAnnotation);
|
||||
InteractorStyle->AddObserver(vtkCommand::WindowLevelEvent,this, &VolumeRenderingViewer::renderWindowAnnotation);
|
||||
}
|
||||
|
||||
this->Interactor->SetInteractorStyle(this->InteractorStyle);
|
||||
@@ -202,7 +204,7 @@ void VolumeRenderingViewer::InstallPipeline() {
|
||||
if (this->Renderer && this->VolumeActor) {
|
||||
this->Renderer->AddVolume(this->VolumeActor);
|
||||
this->Renderer->AddViewProp(annotation);
|
||||
// Renderer->AddObserver(vtkCommand::EndEvent,this, &VolumeRenderingViewer::renderAnnotation);
|
||||
|
||||
this->Renderer->SetBackground(0.0, 0.0, 0.0);
|
||||
}
|
||||
}
|
||||
@@ -330,17 +332,20 @@ vtkImageData *VolumeRenderingViewer::GetInput() {
|
||||
}
|
||||
|
||||
void VolumeRenderingViewer::renderAnnotation() {
|
||||
renderWindowAnnotation();
|
||||
renderOrientationAnnotation();
|
||||
}
|
||||
|
||||
// set FPS
|
||||
double timeInSeconds = Renderer->GetLastRenderTimeInSeconds();
|
||||
double fps = 1.0 / timeInSeconds;
|
||||
void VolumeRenderingViewer::renderWindowAnnotation() {
|
||||
char buff[200]={0};
|
||||
double *range = VolumeActor->GetProperty()->GetScalarOpacity()->GetRange();
|
||||
double wl = (range[0]+range[1])/2.0;
|
||||
double ww = (range[1] - range[0]);
|
||||
sprintf(buff,"FPS:%3.0f\r\nWW:%.0f WL:%.0f", fps,ww,wl);
|
||||
sprintf(buff,"WW:%.0f WL:%.0f", ww,wl);
|
||||
annotation->SetText(0,buff );
|
||||
}
|
||||
|
||||
void VolumeRenderingViewer::renderOrientationAnnotation() {
|
||||
auto camera = Renderer->GetActiveCamera();
|
||||
double dop[4] = {.0, .0, .0, 1.};
|
||||
camera->GetDirectionOfProjection(dop);
|
||||
|
||||
@@ -105,6 +105,8 @@ protected:
|
||||
virtual void UnInstallPipeline();
|
||||
|
||||
void renderAnnotation();
|
||||
void renderWindowAnnotation();
|
||||
void renderOrientationAnnotation();
|
||||
private:
|
||||
VolumeRenderingViewer(const VolumeRenderingViewer &) = delete;
|
||||
void operator=(const VolumeRenderingViewer &) = delete;
|
||||
|
||||
Reference in New Issue
Block a user