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();
123 void onInit(uint)
override
125 DRA::DRW::setCanvasDefaultClearColor(derived(), Color::DarkGray);
135 DRA::DRW::screenshot(derived(),
"viewer_screenshot.png");
143 void readDepthRequest(
double x,
double y,
bool homogeneousNDC =
true)
145 using ReadData = ReadBufferTypes::ReadData;
146 using FloatData = ReadBufferTypes::FloatData;
147 using MatrixType = Base::MatrixType;
156 const auto proj = Base::projectionMatrix();
157 const auto view = Base::viewMatrix();
159 auto size = DRA::DRW::canvasSize(derived());
163 auto callback = [=,
this](
const ReadData&
dt) {
164 const auto& data = std::get<FloatData>(
dt);
166 const float depth = data[0];
168 mReadRequested =
false;
190 void readIdRequest(
double x,
double y, std::function<
void(uint)>
idCallback)
192 using ReadData = ReadBufferTypes::ReadData;
201 auto callback = [=,
this](
const ReadData&
dt) {
202 const auto& data = std::get<ReadBufferTypes::ByteData>(
dt);
205 const uint
id = *(
uint32_t*) &data[0];
207 mReadRequested =
false;
220 auto* derived() {
return static_cast<DRA*
>(
this); }
222 const auto* derived()
const {
return static_cast<const DRA*
>(
this); }