30 : m_corner00(Eigen::Vector3d::Zero())
31 , m_corner10(Eigen::Vector3d::UnitX())
32 , m_corner01(Eigen::Vector3d::UnitY())
33 , m_corner11(Eigen::Vector3d::UnitX() + Eigen::Vector3d::UnitY())
42 const Eigen::Matrix4d& voxelToWorld)
47 m_voxelToWorld = voxelToWorld;
50 const int w = m_image.width();
51 const int h = m_image.height();
55 Eigen::Vector4d c00, c10, c01, c11;
57 switch (m_orientation) {
82 Eigen::Vector4d w00 = m_voxelToWorld * c00;
83 Eigen::Vector4d w10 = m_voxelToWorld * c10;
84 Eigen::Vector4d w01 = m_voxelToWorld * c01;
85 Eigen::Vector4d w11 = m_voxelToWorld * c11;
87 m_corner00 = w00.head<3>();
88 m_corner10 = w10.head<3>();
89 m_corner01 = w01.head<3>();
90 m_corner11 = w11.head<3>();
98 const Eigen::Matrix4d& imageToWorld)
104 const int w = m_image.width();
105 const int h = m_image.height();
107 const Eigen::Vector4d c00(0.0, 0.0, 0.0, 1.0);
108 const Eigen::Vector4d c10(
static_cast<double>(w), 0.0, 0.0, 1.0);
109 const Eigen::Vector4d c01(0.0,
static_cast<double>(h), 0.0, 1.0);
110 const Eigen::Vector4d c11(
static_cast<double>(w),
static_cast<double>(h), 0.0, 1.0);
112 m_corner00 = (imageToWorld * c00).head<3>();
113 m_corner10 = (imageToWorld * c10).head<3>();
114 m_corner01 = (imageToWorld * c01).head<3>();
115 m_corner11 = (imageToWorld * c11).head<3>();
122 return m_orientation;
147 Eigen::Vector3d u = m_corner10 - m_corner00;
148 Eigen::Vector3d v = m_corner01 - m_corner00;
149 Eigen::Vector3d n = u.cross(v).normalized();
153 mat(0, 0) =
static_cast<float>(u.x());
154 mat(1, 0) =
static_cast<float>(u.y());
155 mat(2, 0) =
static_cast<float>(u.z());
157 mat(0, 1) =
static_cast<float>(v.x());
158 mat(1, 1) =
static_cast<float>(v.y());
159 mat(2, 1) =
static_cast<float>(v.z());
161 mat(0, 2) =
static_cast<float>(n.x());
162 mat(1, 2) =
static_cast<float>(n.y());
163 mat(2, 2) =
static_cast<float>(n.z());
165 mat(0, 3) =
static_cast<float>(m_corner00.x());
166 mat(1, 3) =
static_cast<float>(m_corner00.y());
167 mat(2, 3) =
static_cast<float>(m_corner00.z());
176 m_windowCenter = center;
177 m_windowWidth = width;
184 return m_windowCenter;
191 return m_windowWidth;
214 float* p = vertices.data();
217 *p++ =
static_cast<float>(m_corner00.x());
218 *p++ =
static_cast<float>(m_corner00.y());
219 *p++ =
static_cast<float>(m_corner00.z());
220 *p++ = 0.0f; *p++ = 0.0f;
223 *p++ =
static_cast<float>(m_corner10.x());
224 *p++ =
static_cast<float>(m_corner10.y());
225 *p++ =
static_cast<float>(m_corner10.z());
226 *p++ = 1.0f; *p++ = 0.0f;
229 *p++ =
static_cast<float>(m_corner01.x());
230 *p++ =
static_cast<float>(m_corner01.y());
231 *p++ =
static_cast<float>(m_corner01.z());
232 *p++ = 0.0f; *p++ = 1.0f;
235 *p++ =
static_cast<float>(m_corner11.x());
236 *p++ =
static_cast<float>(m_corner11.y());
237 *p++ =
static_cast<float>(m_corner11.z());
238 *p++ = 1.0f; *p++ = 1.0f;
246 indices = { 0, 1, 2, 2, 1, 3 };
Single MRI volume slice rendered as a textured quad with adjustable axis, position,...
3-D brain visualisation using the Qt RHI rendering backend.
SliceOrientation
Orientation for an orthogonal MRI slice.
float windowCenter() const
const QImage & image() const
void setWindowLevel(float center, float width)
static void generateQuadIndices(QVector< unsigned int > &indices)
float windowWidth() const
QMatrix4x4 sliceToWorld() const
void setSlice(const QImage &image, SliceOrientation orientation, int sliceIndex, const Eigen::Matrix4d &voxelToWorld)
void setSliceToWorld(const QImage &image, SliceOrientation orientation, int sliceIndex, const Eigen::Matrix4d &imageToWorld)
void generateQuadVertices(QVector< float > &vertices) const
SliceOrientation orientation() const
void setOpacity(float opacity)