2.12.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit 8bc22f3c authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Various small improvements:

* Implemented GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>::getElementLinear()
* Added support to ImageRepresentationLocal data to DevilImageWriter
* DataContainerInspector shows texel position during picking
parent 08177c74
...@@ -299,7 +299,7 @@ namespace campvis { ...@@ -299,7 +299,7 @@ namespace campvis {
cgt::svec3 lookupTexel(lookupTexelFloat.x, imageSize.y - lookupTexelFloat.y, 0); cgt::svec3 lookupTexel(lookupTexelFloat.x, imageSize.y - lookupTexelFloat.y, 0);
if (lookupTexel.x >= 0 && lookupTexel.y >= 0 && lookupTexel.x < imageSize.x && lookupTexel.y < imageSize.y) { if (lookupTexel.x >= 0 && lookupTexel.y >= 0 && lookupTexel.x < imageSize.x && lookupTexel.y < imageSize.y) {
if (tex->isDepthTexture()) { if (tex->isDepthTexture()) {
emit s_depthChanged(localRep->getElementNormalized(lookupTexel, 0)); emit s_depthChanged(lookupTexel, localRep->getElementNormalized(lookupTexel, 0));
} }
else { else {
if (tex->getDimensions().z != 1) { if (tex->getDimensions().z != 1) {
...@@ -309,7 +309,7 @@ namespace campvis { ...@@ -309,7 +309,7 @@ namespace campvis {
for (size_t i = 0; i < id->getNumChannels(); ++i) { for (size_t i = 0; i < id->getNumChannels(); ++i) {
texel[i] = localRep->getElementNormalized(lookupTexel, i); texel[i] = localRep->getElementNormalized(lookupTexel, i);
} }
emit s_colorChanged(texel); emit s_colorChanged(lookupTexel, texel);
} }
} }
else if (tex->getDimensions().y != 1) { else if (tex->getDimensions().y != 1) {
...@@ -317,7 +317,7 @@ namespace campvis { ...@@ -317,7 +317,7 @@ namespace campvis {
for (size_t i = 0; i < id->getNumChannels(); ++i) { for (size_t i = 0; i < id->getNumChannels(); ++i) {
texel[i] = localRep->getElementNormalized(lookupTexel, i); texel[i] = localRep->getElementNormalized(lookupTexel, i);
} }
emit s_colorChanged(texel); emit s_colorChanged(lookupTexel, texel);
} }
} }
} }
......
...@@ -129,8 +129,8 @@ namespace campvis { ...@@ -129,8 +129,8 @@ namespace campvis {
MetaProperty p_geometryRendererProperties; ///< MetaProperty for the GeometryRenderer MetaProperty p_geometryRendererProperties; ///< MetaProperty for the GeometryRenderer
signals: signals:
void s_colorChanged(const cgt::vec4&); void s_colorChanged(const cgt::svec3& texel, const cgt::vec4&);
void s_depthChanged(float depth); void s_depthChanged(const cgt::svec3& texel, float depth);
private slots: private slots:
/** /**
......
...@@ -227,11 +227,11 @@ namespace campvis { ...@@ -227,11 +227,11 @@ namespace campvis {
this, SIGNAL(dataContainerChanged(const QString&, QtDataHandle)), this, SIGNAL(dataContainerChanged(const QString&, QtDataHandle)),
_canvas, SLOT(onDataContainerChanged(const QString&, QtDataHandle))); _canvas, SLOT(onDataContainerChanged(const QString&, QtDataHandle)));
connect( connect(
_canvas, SIGNAL(s_colorChanged(const cgt::vec4&)), _canvas, SIGNAL(s_colorChanged(const cgt::svec3&, const cgt::vec4&)),
this, SLOT(onColorChanged(const cgt::vec4&))); this, SLOT(onColorChanged(const cgt::svec3&, const cgt::vec4&)));
connect( connect(
_canvas, SIGNAL(s_depthChanged(float)), _canvas, SIGNAL(s_depthChanged(const cgt::svec3&, float)),
this, SLOT(onDepthChanged(float))); this, SLOT(onDepthChanged(const cgt::svec3&, float)));
connect( connect(
this, SIGNAL(dataContainerChanged(const QString&, QtDataHandle)), this, SIGNAL(dataContainerChanged(const QString&, QtDataHandle)),
_dctWidget->getTreeModel(), SLOT(onDataContainerChanged(const QString&, QtDataHandle))); _dctWidget->getTreeModel(), SLOT(onDataContainerChanged(const QString&, QtDataHandle)));
...@@ -540,16 +540,18 @@ namespace campvis { ...@@ -540,16 +540,18 @@ namespace campvis {
} }
void DataContainerInspectorWidget::onColorChanged(const cgt::vec4& color) { void DataContainerInspectorWidget::onColorChanged(const cgt::svec3& texel, const cgt::vec4& color) {
_lblColorVal->setText(QString("Color: [%1, %2, %3, %4]").arg(QString::number(color.r), QString::number(color.g), QString::number(color.b), QString::number(color.a))); _lblColorVal->setText(QString("Color @ [%1, %2, %3]: [%4, %5, %6, %7]")
.arg(QString::number(texel.x), QString::number(texel.y), QString::number(texel.z), QString::number(color.r), QString::number(color.g), QString::number(color.b), QString::number(color.a)));
cgt::ivec4 clamped(cgt::clamp(color * 255.f, 0.f, 255.f)); cgt::ivec4 clamped(cgt::clamp(color * 255.f, 0.f, 255.f));
_colorValWidgetPalette.setColor(QPalette::Background, QColor(clamped.r, clamped.g, clamped.b, clamped.a)); _colorValWidgetPalette.setColor(QPalette::Background, QColor(clamped.r, clamped.g, clamped.b, clamped.a));
_colorValWidget->setPalette(_colorValWidgetPalette); _colorValWidget->setPalette(_colorValWidgetPalette);
} }
void DataContainerInspectorWidget::onDepthChanged(float depth) { void DataContainerInspectorWidget::onDepthChanged(const cgt::svec3& texel, float depth) {
_lblColorVal->setText(QString("Depth: %1").arg(QString::number(depth))); _lblColorVal->setText(QString("Depth @ [%1, %2, %3]: %4")
.arg(QString::number(texel.x), QString::number(texel.y), QString::number(texel.z), QString::number(depth)));
cgt::ivec4 clamped(cgt::clamp(depth * 255.f, 0.f, 255.f)); cgt::ivec4 clamped(cgt::clamp(depth * 255.f, 0.f, 255.f));
_colorValWidgetPalette.setColor(QPalette::Background, QColor(clamped.r, clamped.g, clamped.b, clamped.a)); _colorValWidgetPalette.setColor(QPalette::Background, QColor(clamped.r, clamped.g, clamped.b, clamped.a));
......
...@@ -130,9 +130,9 @@ namespace campvis { ...@@ -130,9 +130,9 @@ namespace campvis {
void onBtnLoadFileClicked(); void onBtnLoadFileClicked();
/// Slot being called when the color under the mouse has changed /// Slot being called when the color under the mouse has changed
void onColorChanged(const cgt::vec4& color); void onColorChanged(const cgt::svec3& texel, const cgt::vec4& color);
/// Slot being called when the depth under the mouse has changed /// Slot being called when the depth under the mouse has changed
void onDepthChanged(float depth); void onDepthChanged(const cgt::svec3& texel, float depth);
protected: protected:
/** /**
......
...@@ -399,10 +399,12 @@ namespace campvis { ...@@ -399,10 +399,12 @@ namespace campvis {
template<typename BASETYPE, size_t NUMCHANNELS> template<typename BASETYPE, size_t NUMCHANNELS>
typename campvis::GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>::ElementType campvis::GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>::getElementLinear(const cgt::vec3 position) const { typename campvis::GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>::ElementType campvis::GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>::getElementLinear(const cgt::vec3 position) const {
// yet to be implemented ElementType toReturn;
// TODO: Check wether pixel/voxel coordinates lie on the edges or on the center of the pixels/voxels for (size_t i = 0; i < NUMCHANNELS; ++i) {
cgtAssert(false, "Yet to be implemented!"); float channelValue = getElementNormalizedLinear(position, i);
return ElementType(0); TypeTraits<BASETYPE, NUMCHANNELS>::setChannel(toReturn, i, TypeNormalizer::denormalizeFromFloat<BASETYPE>(channelValue));
}
return toReturn;
} }
......
...@@ -57,9 +57,16 @@ namespace campvis { ...@@ -57,9 +57,16 @@ namespace campvis {
} }
void DevilImageWriter::updateResult(DataContainer& data) { void DevilImageWriter::updateResult(DataContainer& data) {
ScopedTypedData<RenderData> image(data, p_inputImage.getValue()); // try get Data
DataHandle dh = data.getData(p_inputImage.getValue());
const RenderData* rd = nullptr;
const ImageRepresentationLocal* repLocal = nullptr;
if (dh.getData() != nullptr) {
rd = dynamic_cast<const RenderData*>(dh.getData());
if (const ImageData* id = dynamic_cast<const ImageData*>(dh.getData()))
repLocal = id->getRepresentation<ImageRepresentationLocal>();
if (image != 0) {
std::string filename = p_url.getValue(); std::string filename = p_url.getValue();
std::string extension = cgt::FileSystem::fileExtension(filename); std::string extension = cgt::FileSystem::fileExtension(filename);
std::string filebase = cgt::FileSystem::fullBaseName(filename); std::string filebase = cgt::FileSystem::fullBaseName(filename);
...@@ -68,26 +75,32 @@ namespace campvis { ...@@ -68,26 +75,32 @@ namespace campvis {
extension = "png"; extension = "png";
} }
for (size_t i = 0; i < image->getNumColorTextures(); ++i) { if (rd) {
const ImageRepresentationLocal* id = image->getColorTexture(i)->getRepresentation<ImageRepresentationLocal>(true); for (size_t i = 0; i < rd->getNumColorTextures(); ++i) {
if (id == 0) { const ImageRepresentationLocal* rep = rd->getColorTexture(i)->getRepresentation<ImageRepresentationLocal>(true);
LERROR("Could not download color texture " << i << " from RenderData, skipping."); if (rep == 0) {
continue; LERROR("Could not download color texture " << i << " from RenderData, skipping.");
} continue;
}
WeaklyTypedPointer wtp = id->getWeaklyTypedPointer(); WeaklyTypedPointer wtp = rep->getWeaklyTypedPointer();
writeIlImage(wtp, id->getSize().xy(), filebase + ((image->getNumColorTextures() > 1) ? StringUtils::toString(i) : "") + "." + extension); writeIlImage(wtp, rep->getSize().xy(), filebase + ((rd->getNumColorTextures() > 1) ? StringUtils::toString(i) : "") + "." + extension);
}
if (p_writeDepthImage.getValue() && image->hasDepthTexture()) {
const ImageRepresentationLocal* id = image->getDepthTexture()->getRepresentation<ImageRepresentationLocal>(true);
if (id == 0) {
LERROR("Could not download depth texture from RenderData, skipping.");
} }
else { if (p_writeDepthImage.getValue() && rd->hasDepthTexture()) {
WeaklyTypedPointer wtp = id->getWeaklyTypedPointer(); const ImageRepresentationLocal* rep = rd->getDepthTexture()->getRepresentation<ImageRepresentationLocal>(true);
writeIlImage(wtp, id->getSize().xy(), filebase + ".depth." + extension); if (rep == 0) {
LERROR("Could not download depth texture from RenderData, skipping.");
}
else {
WeaklyTypedPointer wtp = rep->getWeaklyTypedPointer();
writeIlImage(wtp, rep->getSize().xy(), filebase + ".depth." + extension);
}
} }
} }
else if (repLocal) {
WeaklyTypedPointer wtp = repLocal->getWeaklyTypedPointer();
writeIlImage(wtp, repLocal->getSize().xy(), filebase + "." + extension);
}
} }
else { else {
LDEBUG("Could not load RenderData with given ID from pipeline."); LDEBUG("Could not load RenderData with given ID from pipeline.");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment