Commit 99af5733 authored by mmostajab's avatar mmostajab
Browse files

# Take back the updateInfoWidget to its previous position and add a new...

# Take back the updateInfoWidget to its previous position and add a new updateColor function to just update the Color in the label.

# Add the ability to read the color when hovering the mouse into the canvas and dragging the right mouse button.
parent 63f75925
......@@ -232,7 +232,7 @@ namespace campvis {
invalidate();
}
void DataContainerInspectorCanvas::mousePressEvent(tgt::MouseEvent* e)
void DataContainerInspectorCanvas::mouseMoveEvent(tgt::MouseEvent* e)
{
/*if (_renderFullscreen) {
_renderFullscreen = false;
......@@ -244,6 +244,12 @@ namespace campvis {
}
e->ignore();
invalidate();*/
static clock_t lastRunTime = clock();
if(!(clock() - lastRunTime > 0))
{
return;
}
lastRunTime = clock();
if(e->button() == tgt::MouseEvent::MOUSE_BUTTON_RIGHT)
{
......@@ -254,13 +260,21 @@ namespace campvis {
return;
int texIndx = (e->y() / _quadSize.y) * _numTiles.x + (e->x() / _quadSize.x);
int cursorPosX = (float)(e->x() % _quadSize.x) / _quadSize.x * _textures[texIndx]->getWidth();
int cursorPosY = (float)(e->y() % _quadSize.y) / _quadSize.y * _textures[texIndx]->getHeight();
const tgt::Texture* test = _textures[texIndx];
_color = _textures[texIndx]->texelAsFloat(cursorPosX, cursorPosY);
int cursorPosX = (float)(e->x() % _quadSize.x) / _quadSize.x * test->getWidth();
int cursorPosY = (float)(e->y() % _quadSize.y) / _quadSize.y * test->getHeight();
_widget->updateInfoWidget();
int a = 0;
if(texIndx > 1)
{
a= 1;
}
_color = _textures[texIndx]->texelAsFloat(cursorPosX, cursorPosY);
_widget->updateColor();
}
}
......
......@@ -113,7 +113,7 @@ namespace campvis {
* Called on mouse move event on this canvas
* \param e Mouse event arguments
*/
virtual void mousePressEvent(tgt::MouseEvent* e);
virtual void mouseMoveEvent(tgt::MouseEvent* e);
/**
* Called on mouse wheel even on this canvas.
......
......@@ -175,6 +175,20 @@ namespace campvis {
this, SLOT(onBtnSaveToFileClicked()));
}
void DataContainerInspectorWidget::updateColor(){
char bufferR[10];
char bufferG[10];
char bufferB[10];
tgt::Color color = _canvas->getCapturedColor();
itoa((int)(color.r * 255), bufferR, 10);
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));
}
void DataContainerInspectorWidget::updateInfoWidget() {
if (!_inited)
return;
......@@ -225,6 +239,8 @@ namespace campvis {
std::ostringstream ss;
ss << tester->getWorldBounds();
_lblBounds->setText(tr("World Bounds: ") + QString::fromStdString(ss.str()));
//tester->render();
}
#ifdef CAMPVIS_HAS_MODULE_COLUMBIA
else if (const FiberData* tester = dynamic_cast<const FiberData*>(handles.front().second.getData())) {
......@@ -239,18 +255,7 @@ namespace campvis {
#endif
else {
char bufferR[10];
char bufferG[10];
char bufferB[10];
tgt::Color color = _canvas->getCapturedColor();
itoa((int)(color.r * 255), bufferR, 10);
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));
_lblSize->setText(tr("Size: n/a"));
_lblSize->setText(tr("Size: n/a"));
_lblBounds->setText(tr("World Bounds: n/a"));
}
}
......
......@@ -113,9 +113,9 @@ namespace campvis {
void deinit();
/**
* Updates _infoWidget
* Updates color of the info widget
*/
void updateInfoWidget();
void updateColor();
signals:
void dataContainerChanged(const QString&, QtDataHandle);
......@@ -155,6 +155,11 @@ namespace campvis {
*/
QString humanizeBytes(size_t numBytes) const;
/**
* Updates _infoWidget
*/
void updateInfoWidget();
bool _inited;
DataContainer* _dataContainer; ///< The DataContainer this widget is inspecting
......
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