-
Notifications
You must be signed in to change notification settings - Fork 1
/
Pane2D.cpp
53 lines (41 loc) · 1.67 KB
/
Pane2D.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "Pane2D.h"
#include <vtkImageData.h>
#include <vtkImageSliceMapper.h>
#include <vtkImageSlice.h>
#include <vtkRenderWindow.h>
#include "PointSelectionStyle2D.h"
Pane2D::Pane2D(QVTKWidget* qvtkWidget) : Pane(qvtkWidget)
{
this->ImageData = vtkSmartPointer<vtkImageData>::New();
this->ImageSliceMapper = vtkSmartPointer<vtkImageSliceMapper>::New();
this->ImageSlice = vtkSmartPointer<vtkImageSlice>::New();
this->CameraLeftToRightVector.resize(3);
this->CameraLeftToRightVector[0] = -1;
this->CameraLeftToRightVector[1] = 0;
this->CameraLeftToRightVector[2] = 0;
this->CameraBottomToTopVector.resize(3);
this->CameraBottomToTopVector[0] = 0;
this->CameraBottomToTopVector[1] = 1;
this->CameraBottomToTopVector[2] = 0;
}
void Pane2D::SetCameraPosition()
{
double leftToRight[3] = {this->CameraLeftToRightVector[0], this->CameraLeftToRightVector[1], this->CameraLeftToRightVector[2]};
double bottomToTop[3] = {this->CameraBottomToTopVector[0], this->CameraBottomToTopVector[1], this->CameraBottomToTopVector[2]};
static_cast<PointSelectionStyle2D*>(this->SelectionStyle)->SetImageOrientation(leftToRight, bottomToTop);
static_cast<PointSelectionStyle2D*>(this->SelectionStyle)->GetCurrentRenderer()->ResetCamera();
static_cast<PointSelectionStyle2D*>(this->SelectionStyle)->GetCurrentRenderer()->ResetCameraClippingRange();
this->Renderer->ResetCamera();
this->Renderer->ResetCameraClippingRange();
this->Renderer->GetRenderWindow()->Render();
}
void Pane2D::FlipVertically()
{
this->CameraBottomToTopVector[1] *= -1;
SetCameraPosition();
}
void Pane2D::FlipHorizontally()
{
this->CameraLeftToRightVector[0] *= -1;
SetCameraPosition();
}