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 {
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 (tex->isDepthTexture()) {
emit s_depthChanged(localRep->getElementNormalized(lookupTexel, 0));
emit s_depthChanged(lookupTexel, localRep->getElementNormalized(lookupTexel, 0));
}
else {
if (tex->getDimensions().z != 1) {
......@@ -309,7 +309,7 @@ namespace campvis {
for (size_t i = 0; i < id->getNumChannels(); ++i) {
texel[i] = localRep->getElementNormalized(lookupTexel, i);
}
emit s_colorChanged(texel);
emit s_colorChanged(lookupTexel, texel);
}
}
else if (tex->getDimensions().y != 1) {
......@@ -317,7 +317,7 @@ namespace campvis {
for (size_t i = 0; i < id->getNumChannels(); ++i) {
texel[i] = localRep->getElementNormalized(lookupTexel, i);
}
emit s_colorChanged(texel);
emit s_colorChanged(lookupTexel, texel);
}
}
}
......
......@@ -129,8 +129,8 @@ namespace campvis {
MetaProperty p_geometryRendererProperties; ///< MetaProperty for the GeometryRenderer
signals:
void s_colorChanged(const cgt::vec4&);
void s_depthChanged(float depth);
void s_colorChanged(const cgt::svec3& texel, const cgt::vec4&);
void s_depthChanged(const cgt::svec3& texel, float depth);
private slots:
/**
......
......@@ -227,11 +227,11 @@ namespace campvis {
this, SIGNAL(dataContainerChanged(const QString&, QtDataHandle)),
_canvas, SLOT(onDataContainerChanged(const QString&, QtDataHandle)));
connect(
_canvas, SIGNAL(s_colorChanged(const cgt::vec4&)),
this, SLOT(onColorChanged(const cgt::vec4&)));
_canvas, SIGNAL(s_colorChanged(const cgt::svec3&, const cgt::vec4&)),
this, SLOT(onColorChanged(const cgt::svec3&, const cgt::vec4&)));
connect(
_canvas, SIGNAL(s_depthChanged(float)),
this, SLOT(onDepthChanged(float)));
_canvas, SIGNAL(s_depthChanged(const cgt::svec3&, float)),
this, SLOT(onDepthChanged(const cgt::svec3&, float)));
connect(
this, SIGNAL(dataContainerChanged(const QString&, QtDataHandle)),
_dctWidget->getTreeModel(), SLOT(onDataContainerChanged(const QString&, QtDataHandle)));
......@@ -540,16 +540,18 @@ namespace campvis {
}
void DataContainerInspectorWidget::onColorChanged(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)));
void DataContainerInspectorWidget::onColorChanged(const cgt::svec3& texel, const cgt::vec4& color) {
_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));
_colorValWidgetPalette.setColor(QPalette::Background, QColor(clamped.r, clamped.g, clamped.b, clamped.a));
_colorValWidget->setPalette(_colorValWidgetPalette);
}
void DataContainerInspectorWidget::onDepthChanged(float depth) {
_lblColorVal->setText(QString("Depth: %1").arg(QString::number(depth)));
void DataContainerInspectorWidget::onDepthChanged(const cgt::svec3& texel, float 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));
_colorValWidgetPalette.setColor(QPalette::Background, QColor(clamped.r, clamped.g, clamped.b, clamped.a));
......
......@@ -130,9 +130,9 @@ namespace campvis {
void onBtnLoadFileClicked();
/// 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
void onDepthChanged(float depth);
void onDepthChanged(const cgt::svec3& texel, float depth);
protected:
/**
......
......@@ -399,10 +399,12 @@ namespace campvis {
template<typename BASETYPE, size_t NUMCHANNELS>
typename campvis::GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>::ElementType campvis::GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>::getElementLinear(const cgt::vec3 position) const {
// yet to be implemented
// TODO: Check wether pixel/voxel coordinates lie on the edges or on the center of the pixels/voxels
cgtAssert(false, "Yet to be implemented!");
return ElementType(0);
ElementType toReturn;
for (size_t i = 0; i < NUMCHANNELS; ++i) {
float channelValue = getElementNormalizedLinear(position, i);
TypeTraits<BASETYPE, NUMCHANNELS>::setChannel(toReturn, i, TypeNormalizer::denormalizeFromFloat<BASETYPE>(channelValue));
}
return toReturn;
}
......
......@@ -57,9 +57,16 @@ namespace campvis {
}
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 extension = cgt::FileSystem::fileExtension(filename);
std::string filebase = cgt::FileSystem::fullBaseName(filename);
......@@ -68,26 +75,32 @@ namespace campvis {
extension = "png";
}
for (size_t i = 0; i < image->getNumColorTextures(); ++i) {
const ImageRepresentationLocal* id = image->getColorTexture(i)->getRepresentation<ImageRepresentationLocal>(true);
if (id == 0) {
LERROR("Could not download color texture " << i << " from RenderData, skipping.");
continue;
}
if (rd) {
for (size_t i = 0; i < rd->getNumColorTextures(); ++i) {
const ImageRepresentationLocal* rep = rd->getColorTexture(i)->getRepresentation<ImageRepresentationLocal>(true);
if (rep == 0) {
LERROR("Could not download color texture " << i << " from RenderData, skipping.");
continue;
}
WeaklyTypedPointer wtp = id->getWeaklyTypedPointer();
writeIlImage(wtp, id->getSize().xy(), filebase + ((image->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.");
WeaklyTypedPointer wtp = rep->getWeaklyTypedPointer();
writeIlImage(wtp, rep->getSize().xy(), filebase + ((rd->getNumColorTextures() > 1) ? StringUtils::toString(i) : "") + "." + extension);
}
else {
WeaklyTypedPointer wtp = id->getWeaklyTypedPointer();
writeIlImage(wtp, id->getSize().xy(), filebase + ".depth." + extension);
if (p_writeDepthImage.getValue() && rd->hasDepthTexture()) {
const ImageRepresentationLocal* rep = rd->getDepthTexture()->getRepresentation<ImageRepresentationLocal>(true);
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 {
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