Commit 4c17fa37 authored by mmostajab's avatar mmostajab
Browse files

# Adding the color under the mouse cursor window and the color value in a line...

# Adding the color under the mouse cursor window and the color value in a line into the Data Inspector Widget.
parent 99af5733
......@@ -38,6 +38,7 @@
#include "core/datastructures/renderdata.h"
#include "core/datastructures/imagerepresentationgl.h"
#include "core/datastructures/facegeometry.h"
#include "core/datastructures/meshgeometry.h"
#include "core/tools/job.h"
#include "core/classification/tfgeometry1d.h"
#include "core/classification/geometry1dtransferfunction.h"
......@@ -249,30 +250,25 @@ namespace campvis {
{
return;
}
lastRunTime = clock();
if(e->button() == tgt::MouseEvent::MOUSE_BUTTON_RIGHT)
{
tgt::ivec2 dimCanvas = tgt::ivec2(_quadSize.x * _numTiles.x, _quadSize.y * _numTiles.y);
if(e->x() >= dimCanvas.x || e->y() >= dimCanvas.y)
if(e->x() >= dimCanvas.x || e->y() >= dimCanvas.y || e->x() < 0 || e->y() < 0)
return;
int texIndx = (e->y() / _quadSize.y) * _numTiles.x + (e->x() / _quadSize.x);
const tgt::Texture* test = _textures[texIndx];
int cursorPosX = (float)(e->x() % _quadSize.x) / _quadSize.x * test->getWidth();
int cursorPosY = (float)(e->y() % _quadSize.y) / _quadSize.y * test->getHeight();
const tgt::Texture* texturePtr = _textures[texIndx];
const int texWidth = texturePtr->getWidth();
const int texHeight = texturePtr->getHeight();
int a = 0;
if(texIndx > 1)
{
a= 1;
}
int cursorPosX = (float)(e->x() % _quadSize.x) / _quadSize.x * texWidth;
int cursorPosY = (float)(e->y() % _quadSize.y) / _quadSize.y * texHeight;
_color = _textures[texIndx]->texelAsFloat(cursorPosX, cursorPosY);
_color = _textures[texIndx]->texelAsFloat(cursorPosX, texHeight - cursorPosY - 1);
_widget->updateColor();
}
......@@ -360,6 +356,13 @@ namespace campvis {
}
}
else if(const campvis::MeshGeometry* mg = dynamic_cast<const campvis::MeshGeometry*>(it->second.getData())){
// Here the object will be rendered into a texture and the texture will be shown on the output buffer.
//mg->render(GL_POLYGON);
//const tgt::BufferObject* buffer = mg->getColorsBuffer();
}
}
if (maxSlices == 1)
......
......@@ -141,9 +141,32 @@ namespace campvis {
_lblSize = new QLabel(tr("Size: "), _infoWidget);
_infoWidgetLayout->addWidget(_lblSize);
_lblColor = new QLabel(tr("Color: n/a"), _infoWidget);
_infoWidgetLayout->addWidget(_lblColor);
_wdgtColor = new QWidget(this);
//_lblColor = new QLabel(tr("Color:"), _wdgtColor);
_lblColorVal = new QLabel(tr("Color: n/a"), _wdgtColor);
_wdgtColorVal = new QWidget(this);
_wdgtColorVal->setAutoFillBackground(true);
_wdgtColorVal->setFixedSize(16, 16);
_wdgtColorValPalette = new QPalette(palette());
_wdgtColorValPalette->setColor(QPalette::ColorRole::Background, Qt::gray);
_wdgtColorVal->setPalette(*(_wdgtColorValPalette));
_wdgtColorLayout = new QHBoxLayout();
_wdgtColorLayout->setSpacing(0);
_wdgtColorLayout->setMargin(0);
//_wdgtColorLayout->setAlignment(Qt::Alignment::enum_type::AlignLeft);
_wdgtColor->setLayout(_wdgtColorLayout);
//_wdgtColorLayout->addWidget(_lblColor);
_wdgtColorLayout->addWidget(_lblColorVal);
_wdgtColorLayout->addWidget(_wdgtColorVal);
_infoWidgetLayout->addWidget(_wdgtColor);
_lblBounds = new QLabel(tr("World Bounds:"), _infoWidget);
_infoWidgetLayout->addWidget(_lblBounds);
......@@ -186,7 +209,12 @@ namespace campvis {
itoa((int)(color.g * 255), bufferG, 10);
itoa((int)(color.b * 255), bufferB, 10);
_lblColor->setText(QString("Color: ") + QString(bufferR) + QString(" ") + QString(bufferG) + QString(" ") + QString(bufferB));
_lblColorVal->setText(QString("Color: R = ") + QString(bufferR) + QString(" G = ") + QString(bufferG) + QString(" B = ") + QString(bufferB));
QColor qtColor;
qtColor.setRgb(color.r * 255, color.g * 255, color.b * 255);
_wdgtColorValPalette->setColor(QPalette::ColorRole::Background, qtColor);
_wdgtColorVal->setPalette(*_wdgtColorValPalette);
}
void DataContainerInspectorWidget::updateInfoWidget() {
......
......@@ -172,13 +172,17 @@ namespace campvis {
QWidget* _infoWidget; ///< Widget showing the information about the selected QtDataHandle
QVBoxLayout* _infoWidgetLayout; ///< Layout for the _infoWidget
QLabel* _lblName;
QLabel* _lblLocalMemoryFootprint;
QLabel* _lblVideoMemoryFootprint;
QLabel* _lblTimestamp;
QLabel* _lblSize;
QLabel* _lblBounds;
QLabel* _lblColor;
QLabel* _lblName;
QLabel* _lblLocalMemoryFootprint;
QLabel* _lblVideoMemoryFootprint;
QLabel* _lblTimestamp;
QLabel* _lblSize;
QLabel* _lblBounds;
QWidget* _wdgtColor; ///< The widget use to show the color value and the color in a single window
QHBoxLayout* _wdgtColorLayout; ///< Layout for the following widget
QLabel* _lblColorVal; ///< Color Label Value in text
QWidget* _wdgtColorVal; ///< Widget that shows the color value in color
QPalette* _wdgtColorValPalette; ///< Palette which will be used to colorize the color widget
QPushButton* _btnSaveToFile;
static const std::string loggerCat_;
......
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