47 using Base = ViewProjEventDrawer;
48 using DRA = ViewProjEventDrawer::DRA;
50 bool mReadRequested =
false;
60 std::shared_ptr<DrawableObjectVector> mDrawList =
61 std::make_shared<DrawableObjectVector>();
64 uint& id() {
return mId; }
72 "AbstractViewerDrawer requires a ViewProjectionEventDrawer as a "
83 void setDrawableObjectVector(
const std::shared_ptr<DrawableObjectVector>& v)
87 for (
auto obj : *mDrawList) {
95 mDrawList->pushBack(
obj);
96 mDrawList->back()->init();
97 return mDrawList->size() - 1;
102 mDrawList->pushBack(std::move(
obj));
103 mDrawList->back()->init();
104 return mDrawList->size() - 1;
112 Box3d bb = mDrawList->boundingBox();
130 void onInit(uint)
override
132 DRA::DRW::setCanvasDefaultClearColor(derived(), Color::DarkGray);
141 case Key::R: fitScene();
break;
144 DRA::DRW::screenshot(derived(),
"viewer_screenshot.png");
152 uint canvasViewId()
const {
return DRA::DRW::canvasViewId(derived()); }
154 void readDepthRequest(
double x,
double y,
bool homogeneousNDC =
true)
156 using ReadData = ReadBufferTypes::ReadData;
157 using FloatData = ReadBufferTypes::FloatData;
158 using MatrixType = Base::MatrixType;
167 const auto proj = Base::projectionMatrix();
168 const auto view = Base::viewMatrix();
170 auto size = DRA::DRW::canvasSize(derived());
174 auto callback = [=,
this](
const ReadData&
dt) {
175 const auto& data = std::get<FloatData>(
dt);
177 const float depth = data[0];
179 mReadRequested =
false;
201 void readIdRequest(
double x,
double y, std::function<
void(uint)>
idCallback)
203 using ReadData = ReadBufferTypes::ReadData;
212 auto callback = [=,
this](
const ReadData&
dt) {
213 const auto& data = std::get<ReadBufferTypes::ByteData>(
dt);
216 const uint
id = *(
uint32_t*) &data[0];
218 mReadRequested =
false;
231 auto* derived() {
return static_cast<DRA*
>(
this); }
233 const auto* derived()
const {
return static_cast<const DRA*
>(
this); }
PointType unprojectScreenPosition(const PointType &screenPos, const Matrix44 &modelViewProjection, const Point4< typename Matrix44::Scalar > &viewport, bool homogeneousNDC)
Unprojects a screen position to a 3D point.
Definition matrix_camera.h:271