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

Commit 14b77cc2 authored by schultezub's avatar schultezub
Browse files

cleaned up DataContainerInspectorCanvas and added fullscreen view on double click

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@354 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent c9a5d18b
......@@ -124,7 +124,11 @@ namespace campvis {
if (_argc > 0) {
// ugly hack
std::string basePath(_argv[0]);
basePath = tgt::FileSystem::parentDir(tgt::FileSystem::parentDir(tgt::FileSystem::parentDir(basePath)));
basePath = tgt::FileSystem::parentDir(basePath);
ShdrMgr.addPath(basePath);
ShdrMgr.addPath(basePath + "/core/glsl");
basePath = tgt::FileSystem::parentDir(tgt::FileSystem::parentDir(basePath));
ShdrMgr.addPath(basePath);
ShdrMgr.addPath(basePath + "/core/glsl");
......
......@@ -39,9 +39,7 @@
#include "core/datastructures/imagedatagl.h"
#include "core/datastructures/facegeometry.h"
#include "core/tools/job.h"
#include "core/tools/quadrenderer.h"
#include "application/gui/datacontainertreewidget.h"
namespace campvis {
......@@ -50,12 +48,10 @@ namespace campvis {
, _dataContainer(0)
, _paintShader(0)
, _quad(0)
, dimX_(0)
, dimY_(0)
, scaledWidth_(0)
, scaledHeight_(0)
, selected_(0)
, fullscreen_(false)
, _numTiles(0, 0)
, _quadSize(0, 0)
, _selectedTexture(0)
, _renderFullscreen(false)
{
makeCurrent();
......@@ -79,8 +75,11 @@ namespace campvis {
_paintShader->setAttributeLocation(0, "in_Position");
_paintShader->setAttributeLocation(1, "in_TexCoords");
createQuad();
// set this as painter to get notified when window size changes
setPainter(this, false);
getEventHandler()->addListenerToFront(this);
}
void DataContainerInspectorCanvas::deinit() {
......@@ -179,12 +178,9 @@ namespace campvis {
setWindowTitle(title);*/
// update layout dimensions
dimX_ = (int)ceil(sqrt((float)textures.size()));
dimY_ = ceil((float)textures.size() / dimX_);
scaledWidth_ = size_.x / dimX_;
scaledHeight_ = size_.y / dimY_;
createQuad(scaledWidth_, scaledHeight_);
_numTiles.x = ceil(sqrt(static_cast<float>(textures.size())));
_numTiles.y = ceil(static_cast<float>(textures.size()) / _numTiles.x);
_quadSize = size_ / _numTiles;
_paintShader->activate();
......@@ -195,20 +191,23 @@ namespace campvis {
tu.activate();
_paintShader->setUniform("_texture._texture", tu.getUnitNumber());
if (fullscreen_) {
if(selected_ >= 0 && selected_ < (int)textures.size()) {
paintTexture(textures[selected_]);
if (_renderFullscreen) {
if(_selectedTexture >= 0 && _selectedTexture < (int)textures.size()) {
tgt::mat4 scaleMatrix = tgt::mat4::createScale(tgt::vec3(size_, 1.f));
_paintShader->setUniform("_modelMatrix", scaleMatrix);
paintTexture(textures[_selectedTexture]);
}
}
else {
for (int y = 0; y < dimY_; ++y) {
for (int x = 0; x < dimX_; ++x) {
int index = (dimX_ * y) + x;
for (int y = 0; y < _numTiles.y; ++y) {
for (int x = 0; x < _numTiles.y; ++x) {
int index = (_numTiles.x * y) + x;
if (index >= static_cast<int>(textures.size()))
break;
tgt::mat4 translation = tgt::mat4::createTranslation(tgt::vec3(scaledWidth_ * x, scaledHeight_ * y, 0.f));
_paintShader->setUniform("_modelMatrix", translation);
tgt::mat4 scaleMatrix = tgt::mat4::createScale(tgt::vec3(_quadSize, 1.f));
tgt::mat4 translation = tgt::mat4::createTranslation(tgt::vec3(_quadSize.x * x, _quadSize.y * y, 0.f));
_paintShader->setUniform("_modelMatrix", translation * scaleMatrix);
paintTexture(textures[index]);
}
}
......@@ -234,13 +233,13 @@ namespace campvis {
GLJobProc.enqueueJob(this, new CallMemberFuncJob<DataContainerInspectorCanvas>(this, &DataContainerInspectorCanvas::paint), OpenGLJobProcessor::PaintJob);
}
void DataContainerInspectorCanvas::createQuad(float width, float height) {
void DataContainerInspectorCanvas::createQuad() {
std::vector<tgt::vec3> vertices, texCorods;
vertices.push_back(tgt::vec3( 0.f, 0.f, 0.f));
vertices.push_back(tgt::vec3(width, 0.f, 0.f));
vertices.push_back(tgt::vec3(width, height, 0.f));
vertices.push_back(tgt::vec3( 0.f, height, 0.f));
vertices.push_back(tgt::vec3(1.f, 0.f, 0.f));
vertices.push_back(tgt::vec3(1.f, 1.f, 0.f));
vertices.push_back(tgt::vec3( 0.f, 1.f, 0.f));
texCorods.push_back(tgt::vec3(0.f, 1.f, 0.f));
texCorods.push_back(tgt::vec3(1.f, 1.f, 0.f));
texCorods.push_back(tgt::vec3(1.f, 0.f, 0.f));
......@@ -255,4 +254,17 @@ namespace campvis {
invalidate();
}
void DataContainerInspectorCanvas::mouseDoubleClickEvent(tgt::MouseEvent* e) {
if (_renderFullscreen) {
_renderFullscreen = false;
}
else {
tgt::ivec2 selectedIndex(e->x() / _quadSize.x, e->y() / _quadSize.y);
_selectedTexture = (selectedIndex.y * _numTiles.x) + selectedIndex.x;
_renderFullscreen = true;
}
e->accept();
invalidate();
}
}
\ No newline at end of file
......@@ -32,6 +32,8 @@
#include "sigslot/sigslot.h"
#include "tgt/painter.h"
#include "tgt/event/eventlistener.h"
#include "tgt/event/mouseevent.h"
#include "tgt/qt/qtcontextmanager.h"
#include "tgt/qt/qtthreadedcanvas.h"
#include "tbb/include/tbb/mutex.h"
......@@ -51,7 +53,7 @@ namespace campvis {
class DataHandle;
class FaceGeometry;
class DataContainerInspectorCanvas : public tgt::QtThreadedCanvas, tgt::Painter, public sigslot::has_slots<> {
class DataContainerInspectorCanvas : public tgt::QtThreadedCanvas, tgt::Painter, public tgt::EventListener, public sigslot::has_slots<> {
Q_OBJECT;
public:
......@@ -98,6 +100,12 @@ namespace campvis {
/// This is meant be overridden to adjust camera settings to new canvas dimensions
virtual void sizeChanged(const tgt::ivec2&);
/**
* Called on double click event on this canvas
* \param e Mouse event arguments
*/
virtual void mouseDoubleClickEvent(tgt::MouseEvent* e);
private slots:
protected:
......@@ -114,25 +122,29 @@ namespace campvis {
*/
void invalidate();
/**
* Renders the given texture.
* Binds the texture to the shader, sets the uniforms and renders the quad.
* \param texture The texture to render.
*/
void paintTexture(const tgt::Texture* texture);
void createQuad(float width, float height);
/**
* Creates the quad used for rendering the textures.
*/
void createQuad();
DataContainer* _dataContainer; ///< The DataContainer this widget is inspecting
std::map<std::string, DataHandle> _handles; ///< Local copy of the DataHandles to inspect
tbb::mutex _localMutex;
tgt::Shader* _paintShader;
FaceGeometry* _quad;
int dimX_;
int dimY_;
tbb::mutex _localMutex; ///< Mutex protecting the local members
int scaledWidth_;
int scaledHeight_;
tgt::Shader* _paintShader; ///< GLSL shader for rendering the textures
FaceGeometry* _quad; ///< Quad used for rendering
size_t selected_;
bool fullscreen_;
tgt::ivec2 _numTiles; ///< number of tiles on texture overview
tgt::ivec2 _quadSize; ///< size in pixels for each tile in overview
size_t _selectedTexture; ///< index of selected texture for fullscreen view
bool _renderFullscreen; ///< flag whether to render in full screen
};
}
......
......@@ -126,7 +126,8 @@ namespace campvis {
if (AbstractPipeline* pipeline = dynamic_cast<AbstractPipeline*>(ptr)) {
_selectedPipeline = pipeline;
_selectedProcessor = 0;
_dcInspectorCanvas->setDataContainer(&_selectedPipeline->getDataContainer());
if (_dcInspectorCanvas != 0)
_dcInspectorCanvas->setDataContainer(&_selectedPipeline->getDataContainer());
if (_dcInspectorWidget != 0)
onBtnShowDataContainerInspectorClicked();
......
......@@ -121,6 +121,7 @@ namespace campvis {
_renderTargetID.setValue("combine");
_pgGenerator.p_geometryID.connect(&_vmEepGenerator.p_geometryID);
_pgGenerator.p_geometryID.connect(&_eepGenerator.p_geometryID);
_vmgGenerator.p_mirrorID.connect(&_vmEepGenerator.p_mirrorID);
_vmgGenerator.p_mirrorID.connect(&_vmRenderer.p_geometryID);
_vmgGenerator.p_mirrorCenter.setValue(tgt::vec3(0.f, 0.f, -20.f));
......
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