* Fixed tgt::Texture::depthAsFloat()

* Rearranged DataContainerInspectorWidget layout to use less space
* Added option to render custom channels in DataContainerInspectorCanvas
parent 7ea361ff
......@@ -46,6 +46,11 @@ uniform int _sliceNumber;
uniform vec4 _color;
uniform bool _isDepthTexture;
uniform bool _renderRChannel;
uniform bool _renderGChannel;
uniform bool _renderBChannel;
uniform bool _renderAChannel;
const vec4 checkerboardColor1 = vec4(0.90, 0.90, 0.90, 1.0);
const vec4 checkerboardColor2 = vec4(0.50, 0.50, 0.50, 1.0);
......@@ -94,6 +99,15 @@ void main() {
}
}
if (! _renderRChannel)
out_Color.r = 0.0;
if (! _renderGChannel)
out_Color.g = 0.0;
if (! _renderBChannel)
out_Color.b = 0.0;
if (! _renderAChannel)
out_Color.a = 1.0;
// mix with fancy checkerboard pattern:
if ((mod(ex_TexCoord.x * 10.0, 2.0) > 1.0) ^^ (mod(ex_TexCoord.y * 10.0, 2.0) > 1.0))
out_Color = mix(checkerboardColor1, out_Color, out_Color.a);
......
......@@ -50,6 +50,10 @@ namespace campvis {
, p_currentSlice("CurrentSlice", "Slice", -1, -1, -1)
, p_meshSolidColor("MeshSolidColor", "Mesh Solid Color", tgt::vec4(.5f, .75f, .5f, 1), tgt::vec4(0.0f), tgt::vec4(1.0f))
, p_transferFunction("TransferFunction", "Transfer Function", new Geometry1DTransferFunction(256, tgt::vec2(0.f, 1.f)))
, p_renderRChannel("RenderRChannel", "Render Red Channel", true)
, p_renderGChannel("RenderGChannel", "Render Green Channel", true)
, p_renderBChannel("RenderBChannel", "Render Blue Channel", true)
, p_renderAChannel("RenderAChannel", "Render Alpha Channel", true)
, _dataContainer(0)
, _paintShader(0)
, _quad(0)
......@@ -76,6 +80,10 @@ namespace campvis {
addProperty(&p_currentSlice);
addProperty(&p_transferFunction);
addProperty(&p_meshSolidColor);
addProperty(&p_renderRChannel);
addProperty(&p_renderGChannel);
addProperty(&p_renderBChannel);
addProperty(&p_renderAChannel);
}
DataContainerInspectorCanvas::~DataContainerInspectorCanvas() {
......@@ -193,6 +201,11 @@ namespace campvis {
_paintShader->setUniform("_texture2d", unit2d.getUnitNumber());
_paintShader->setUniform("_texture3d", unit3d.getUnitNumber());
_paintShader->setUniform("_renderRChannel", p_renderRChannel.getValue());
_paintShader->setUniform("_renderGChannel", p_renderGChannel.getValue());
_paintShader->setUniform("_renderBChannel", p_renderBChannel.getValue());
_paintShader->setUniform("_renderAChannel", p_renderAChannel.getValue());
for (int y = 0; y < _numTiles.y; ++y) {
for (int x = 0; x < _numTiles.x; ++x) {
int index = (_numTiles.x * y) + x;
......@@ -290,6 +303,10 @@ namespace campvis {
}
void DataContainerInspectorCanvas::drawGeomteryData(const campvis::GeometryData* mg, tgt::Texture* colorBuffer, const int& trackballndx) {
// avoid FRAMEBUFFER_INCOMPLETE_DIMENSIONS error
if (colorBuffer->getDimensions() != _depthBuffer->getDimensions())
return;
glPushAttrib(GL_ALL_ATTRIB_BITS);
/// Activate the shader for geometry Rendering.
......@@ -598,7 +615,6 @@ namespace campvis {
tgt::Texture* colorBuffer = new tgt::Texture(0, tgt::ivec3(width(), height(), 1), GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, tgt::Texture::LINEAR);
/// Render the object on the buffers.
glewExperimental = true;
drawGeomteryData(gd, colorBuffer, nMeshGeometry++);
geomTexInfo._texture = colorBuffer;
......
......@@ -177,6 +177,11 @@ namespace campvis {
Vec4Property p_meshSolidColor; ///< Color used to render the mesh object
TransferFunctionProperty p_transferFunction; ///< Transfer function
BoolProperty p_renderRChannel; /// Flag whether to render Red channel
BoolProperty p_renderGChannel; /// Flag whether to render Green channel
BoolProperty p_renderBChannel; /// Flag whether to render Blue channel
BoolProperty p_renderAChannel; /// Flag whether to render Alpha channel
private slots:
/**
* Slot being called when a QtDataHandle has been added to the DataContainer.
......
......@@ -72,6 +72,19 @@ namespace campvis {
, _mainLayout(0)
, _infoWidget(0)
, _infoWidgetLayout(0)
, _lblName(0)
, _lblLocalMemoryFootprint(0)
, _lblVideoMemoryFootprint(0)
, _lblTimestamp(0)
, _lblSize(0)
, _lblBounds(0)
, _colorWidget(0)
, _colorWidgetLayout(0)
, _lblColorVal(0)
, _colorValWidget(0)
, _ColorValWidgetPalette(0)
, _btnLoadFile(0)
, _btnSaveToFile(0)
, _propEditorWid(0)
{
setupGUI();
......@@ -114,34 +127,52 @@ namespace campvis {
void DataContainerInspectorWidget::setupGUI() {
setWindowTitle(tr("DataContainer Inspector"));
_mainLayout = new QHBoxLayout();
_mainLayout = new QGridLayout();
_mainLayout->setSpacing(4);
setLayout(_mainLayout);
// left column
_dctWidget = new DataContainerTreeWidget(this);
_dctWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
_dctWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
_mainLayout->addWidget(_dctWidget);
_dctWidget->setMinimumWidth(150);
_mainLayout->addWidget(_dctWidget, 0, 0);
_btnLoadFile = new QPushButton(tr("Load File"), _infoWidget);
_mainLayout->addWidget(_btnLoadFile, 1, 0);
#ifdef CAMPVIS_HAS_MODULE_DEVIL
_btnSaveToFile = new QPushButton(tr("Save to File"), _infoWidget);
_btnSaveToFile->setDisabled(true);
_mainLayout->addWidget(_btnSaveToFile, 2, 0);
connect(_btnSaveToFile, SIGNAL(clicked()), this, SLOT(onBtnSaveToFileClicked()));
#endif
// right column
_infoWidget = new QWidget(this);
_infoWidgetLayout = new QVBoxLayout();
_infoWidgetLayout = new QGridLayout();
_infoWidgetLayout->setSpacing(4);
_infoWidget->setLayout(_infoWidgetLayout);
_lblName = new QLabel(QString("Name: "), _infoWidget);
_infoWidgetLayout->addWidget(_lblName);
_infoWidgetLayout->addWidget(_lblName, 0, 0);
_lblLocalMemoryFootprint = new QLabel(QString("Local Memory Footprint: "), _infoWidget);
_infoWidgetLayout->addWidget(_lblLocalMemoryFootprint);
_lblTimestamp = new QLabel("Timestamp: ", _infoWidget);
_infoWidgetLayout->addWidget(_lblTimestamp, 0, 1);
_lblVideoMemoryFootprint = new QLabel(QString("Video Memory Footprint: "), _infoWidget);
_infoWidgetLayout->addWidget(_lblVideoMemoryFootprint);
_lblLocalMemoryFootprint = new QLabel(QString("Local Memory: "), _infoWidget);
_infoWidgetLayout->addWidget(_lblLocalMemoryFootprint, 1, 0);
_lblTimestamp = new QLabel("Timestamp: ", _infoWidget);
_infoWidgetLayout->addWidget(_lblTimestamp);
_lblVideoMemoryFootprint = new QLabel(QString("Video Memory: "), _infoWidget);
_infoWidgetLayout->addWidget(_lblVideoMemoryFootprint, 1, 1);
_lblSize = new QLabel(tr("Size: "), _infoWidget);
_infoWidgetLayout->addWidget(_lblSize);
_infoWidgetLayout->addWidget(_lblSize, 2, 0);
_lblBounds = new QLabel(tr("World Bounds:"), _infoWidget);
_infoWidgetLayout->addWidget(_lblBounds, 3, 0, 1, 2);
_colorWidget = new QWidget(this);
_lblColorVal = new QLabel(tr("Color: n/a"), _colorWidget);
......@@ -162,40 +193,17 @@ namespace campvis {
_colorWidgetLayout->addWidget(_lblColorVal);
_colorWidgetLayout->addWidget(_colorValWidget);
_infoWidgetLayout->addWidget(_colorWidget);
_lblBounds = new QLabel(tr("World Bounds:"), _infoWidget);
_infoWidgetLayout->addWidget(_lblBounds);
QWidget* btnWidget = new QWidget(this);
QGridLayout* gridLayout = new QGridLayout();
btnWidget->setLayout(gridLayout);
#ifdef CAMPVIS_HAS_MODULE_DEVIL
_btnSaveToFile = new QPushButton(tr("Save to File"), _infoWidget);
gridLayout->addWidget(_btnSaveToFile, 0, 0);
connect(
_btnSaveToFile, SIGNAL(clicked()),
this, SLOT(onBtnSaveToFileClicked()));
_btnSaveToFile->setDisabled(true);
#endif
_btnLoadFile = new QPushButton(tr("Load File"), _infoWidget);
gridLayout->addWidget(_btnLoadFile, 0, 1);
_infoWidgetLayout->addWidget(btnWidget);
_infoWidgetLayout->addWidget(_colorWidget, 4, 0, 1, 2);
_canvas = new DataContainerInspectorCanvas(_infoWidget);
_canvas->setMinimumSize(QSize(100, 100));
_infoWidgetLayout->addWidget(_canvas, 1);
_infoWidgetLayout->addWidget(_canvas, 5, 0, 1, 2);
_pcWidget = new PropertyCollectionWidget(_infoWidget);
_pcWidget->updatePropCollection(_canvas, _dataContainer);
_infoWidgetLayout->addWidget(_pcWidget);
_infoWidgetLayout->addWidget(_pcWidget, 6, 0, 1, 2);
_mainLayout->addWidget(_infoWidget, 1);
_mainLayout->addWidget(_infoWidget, 0, 1, 3, 1);
qRegisterMetaType<QtDataHandle>("QtDataHandle");
connect(
......@@ -275,6 +283,13 @@ namespace campvis {
ss << tester->getWorldBounds();
_lblBounds->setText(tr("World Bounds: ") + QString::fromStdString(ss.str()));
_canvas->p_currentSlice.setVisible(tester->getDimensionality() == 3);
_canvas->p_transferFunction.setVisible(true);
_canvas->p_meshSolidColor.setVisible(false);
_canvas->p_renderRChannel.setVisible(true);
_canvas->p_renderGChannel.setVisible(true);
_canvas->p_renderBChannel.setVisible(true);
_canvas->p_renderAChannel.setVisible(true);
}
else if (const GeometryData* tester = dynamic_cast<const GeometryData*>(handles.front().second.getData())) {
_lblSize->setText(tr("Size: n/a"));
......@@ -282,6 +297,14 @@ namespace campvis {
std::ostringstream ss;
ss << tester->getWorldBounds();
_lblBounds->setText(tr("World Bounds: ") + QString::fromStdString(ss.str()));
_canvas->p_currentSlice.setVisible(false);
_canvas->p_transferFunction.setVisible(false);
_canvas->p_meshSolidColor.setVisible(true);
_canvas->p_renderRChannel.setVisible(false);
_canvas->p_renderGChannel.setVisible(false);
_canvas->p_renderBChannel.setVisible(false);
_canvas->p_renderAChannel.setVisible(false);
}
else if (const RenderData* tester = dynamic_cast<const RenderData*>(handles.front().second.getData())) {
const ImageData* id = tester->getNumColorTextures() > 0 ? tester->getColorTexture() : tester->getDepthTexture();
......@@ -298,6 +321,14 @@ namespace campvis {
_lblSize->setText(tr("Size: n/a"));
_lblBounds->setText(tr("World Bounds: n/a"));
}
_canvas->p_currentSlice.setVisible(false);
_canvas->p_transferFunction.setVisible(true);
_canvas->p_meshSolidColor.setVisible(false);
_canvas->p_renderRChannel.setVisible(true);
_canvas->p_renderGChannel.setVisible(true);
_canvas->p_renderBChannel.setVisible(true);
_canvas->p_renderAChannel.setVisible(true);
}
#ifdef CAMPVIS_HAS_MODULE_COLUMBIA
else if (const FiberData* tester = dynamic_cast<const FiberData*>(handles.front().second.getData())) {
......@@ -322,8 +353,8 @@ namespace campvis {
_canvas->p_transferFunction.setImageHandle(DataHandle(0));
}
_lblLocalMemoryFootprint->setText("Local Memory Footprint: " + humanizeBytes(_localFootprint));
_lblVideoMemoryFootprint->setText("Video Memory Footprint: " + humanizeBytes(_videoFootprint));
_lblLocalMemoryFootprint->setText("Local Memory: " + humanizeBytes(_localFootprint));
_lblVideoMemoryFootprint->setText("Video Memory: " + humanizeBytes(_videoFootprint));
// update DataHandles for the DataContainerInspectorCanvas
_canvas->setDataHandles(handles);
......
......@@ -40,6 +40,7 @@
#include <QWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QGridLayout>
#include <QString>
#include <QPushButton>
......@@ -182,9 +183,9 @@ namespace campvis {
DataContainerInspectorCanvas* _canvas; ///< The OpenGL canvas for rendering the DataContainer's contents
PropertyCollectionWidget* _pcWidget;
QHBoxLayout* _mainLayout; ///< Layout for this widget
QGridLayout* _mainLayout; ///< Layout for this widget
QWidget* _infoWidget; ///< Widget showing the information about the selected QtDataHandle
QVBoxLayout* _infoWidgetLayout; ///< Layout for the _infoWidget
QGridLayout* _infoWidgetLayout; ///< Layout for the _infoWidget
QLabel* _lblName;
QLabel* _lblLocalMemoryFootprint;
......@@ -197,11 +198,11 @@ namespace campvis {
QLabel* _lblColorVal; ///< Color Label Value in text
QWidget* _colorValWidget; ///< Widget that shows the color value in color
QPalette* _ColorValWidgetPalette; ///< Palette which will be used to colorize the color widget
QPushButton* _btnSaveToFile;
// Added by Hossain Mahmud <mahmud@in.tum.de>
// Date: January 02, 2014
QPushButton* _btnLoadFile;
QPushButton* _btnSaveToFile;
DataContainerFileLoaderWidget* _propEditorWid;
static const std::string loggerCat_;
......
......@@ -658,9 +658,13 @@ tgt::Color Texture::texelAsFloat(size_t x, size_t y, size_t z) const {
float Texture::depthAsFloat(size_t x, size_t y) const {
float ret = 0.0f;
switch(format_) {
case GL_DEPTH_COMPONENT:
switch(dataType_) {
switch (format_) {
case GL_DEPTH_COMPONENT: // fallthrough
case GL_DEPTH_COMPONENT16: // fallthrough
case GL_DEPTH_COMPONENT24: // fallthrough
case GL_DEPTH_COMPONENT32: // fallthrough
case GL_DEPTH_COMPONENT32F:
switch (dataType_) {
case GL_UNSIGNED_BYTE: {
ret = (float )(texel<uint8_t>(x,y) / 0xFF);
break;
......@@ -676,8 +680,10 @@ float Texture::depthAsFloat(size_t x, size_t y) const {
default:
LWARNINGC("tgt.texture", "depthAsFloat: Unknown format!");
}
break;
default:
LWARNINGC("tgt.texture", "depthAsFloat: Unknown format!");
break;
}
return ret;
......
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