47 using Base = ViewProjEventDrawer;
48 using DRA = ViewProjEventDrawer::DRA;
50 bool mReadRequested =
false;
51 bool mPBRMode =
false;
61 std::shared_ptr<DrawableObjectVector> mDrawList =
62 std::make_shared<DrawableObjectVector>();
65 uint& id() {
return mId; }
73 "AbstractViewerDrawer requires a ViewProjectionEventDrawer as a "
84 void setDrawableObjectVector(
const std::shared_ptr<DrawableObjectVector>& v)
88 for (
auto obj : *mDrawList) {
96 mDrawList->pushBack(
obj);
97 mDrawList->back()->init();
98 return mDrawList->size() - 1;
103 mDrawList->pushBack(std::move(
obj));
104 mDrawList->back()->init();
105 return mDrawList->size() - 1;
113 Box3d bb = mDrawList->boundingBox();
123 bool isPBREnabled()
const {
return mPBRMode; }
125 void setPBR(
bool enable) { mPBRMode = enable; }
127 void enablePBR() { setPBR(
true); }
129 void disablePBR() { setPBR(
false); }
139 void onInit(uint)
override
141 DRA::DRW::setCanvasDefaultClearColor(derived(), Color::DarkGray);
151 DRA::DRW::screenshot(derived(),
"viewer_screenshot.png");
159 void readDepthRequest(
double x,
double y,
bool homogeneousNDC =
true)
161 using ReadData = ReadBufferTypes::ReadData;
162 using FloatData = ReadBufferTypes::FloatData;
163 using MatrixType = Base::MatrixType;
172 const auto proj = Base::projectionMatrix();
173 const auto view = Base::viewMatrix();
175 auto size = DRA::DRW::canvasSize(derived());
179 auto callback = [=,
this](
const ReadData&
dt) {
180 const auto& data = std::get<FloatData>(
dt);
182 const float depth = data[0];
184 mReadRequested =
false;
206 void readIdRequest(
double x,
double y, std::function<
void(uint)>
idCallback)
208 using ReadData = ReadBufferTypes::ReadData;
217 auto callback = [=,
this](
const ReadData&
dt) {
218 const auto& data = std::get<ReadBufferTypes::ByteData>(
dt);
221 const uint
id = *(
uint32_t*) &data[0];
223 mReadRequested =
false;
236 auto* derived() {
return static_cast<DRA*
>(
this); }
238 const auto* derived()
const {
return static_cast<const DRA*
>(
this); }