Commit f9d965d3 authored by Mike Kremer's avatar Mike Kremer
Browse files

Adapted stereo settings context menu to directly change values when changing the sliders.

Added option entries for philips stereo mode.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@7568 383ad7c9-94d9-4d36-a494-682f7c89f535
parent a8be68eb
......@@ -139,6 +139,18 @@ static std::vector<float> anaglyphRightEyeColors_ = std::vector<float> (9, 0.0);
/// mouse cursor depth picking in stereo mode
static bool stereoMousePick_ = true;
/// philips stereo header content type
static int stereoPhilipsContentType_ = 3; // Game
/// philips stereo header factor
static int stereoPhilipsFactor_ = 64;
/// philips stereo header offset
static int stereoPhilipsOffset_ = 128;
/// philips stereo header select
static int stereoPhilipsSelect_ = 0; // Display's defaults
/// Store the synchronization mode
static bool synchronization_ = false;
......@@ -346,7 +358,7 @@ QString pluginDirStr() { return pluginDir_.absolutePath(); }
QString shaderDirStr() { return shaderDir_.absolutePath(); }
QString textureDirStr() { return textureDir_.absolutePath(); }
QString licenseDirStr() { return licenseDir_.absolutePath(); }
QString scriptDirStr() { return scriptDir_.absolutePath(); }
QString scriptDirStr() { return scriptDir_.absolutePath(); }
QString iconDirStr() { return iconDir_.absolutePath(); }
QString translationsDirStr() { return translationsDir_.absolutePath(); }
QString fontsDirStr() { return fontsDir_.absolutePath(); }
......@@ -639,6 +651,54 @@ bool stereoMousePick( ) {
return stereoMousePick_;
}
/// Store philips stereo header content type
void stereoPhilipsContent( int _content )
{
stereoPhilipsContentType_ = _content;
}
/// get philips stereo header content type
int stereoPhilipsContent( )
{
return stereoPhilipsContentType_;
}
/// Store philips stereo header factor
void stereoPhilipsFactor( int _factor )
{
stereoPhilipsFactor_ = _factor;
}
/// get philips stereo header factor
int stereoPhilipsFactor( )
{
return stereoPhilipsFactor_;
}
/// Store philips stereo header offset
void stereoPhilipsOffset( int _offset )
{
stereoPhilipsOffset_ = _offset;
}
/// get philips stereo header offset
int stereoPhilipsOffset( )
{
return stereoPhilipsOffset_;
}
/// Store philips stereo header select
void stereoPhilipsSelect( int _select )
{
stereoPhilipsSelect_ = _select;
}
/// get philips stereo header select
int stereoPhilipsSelect( )
{
return stereoPhilipsSelect_;
}
/// Store synchronization mode setting
void synchronization( bool _synchronization ) {
synchronization_ = _synchronization;
......
......@@ -496,6 +496,38 @@ bool dataDir(QString _dir);
DLLEXPORT
bool stereoMousePick( );
/// Store philips stereo header content type
DLLEXPORT
void stereoPhilipsContent( int _content );
/// get philips stereo header content type
DLLEXPORT
int stereoPhilipsContent( );
/// Store philips stereo header factor
DLLEXPORT
void stereoPhilipsFactor( int _factor );
/// get philips stereo header factor
DLLEXPORT
int stereoPhilipsFactor( );
/// Store philips stereo header offset cc
DLLEXPORT
void stereoPhilipsOffset( int _offset );
/// get philips stereo header offset cc
DLLEXPORT
int stereoPhilipsOffset( );
/// Store philips stereo header select
DLLEXPORT
void stereoPhilipsSelect( int _select );
/// get philips stereo header select
DLLEXPORT
int stereoPhilipsSelect( );
/// Store synchronization setting
DLLEXPORT
void synchronization( bool _synchronization );
......
......@@ -526,9 +526,33 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
stereoSettingsWidget_ = new StereoSettingsWidget(this);
// Make it look like a dialog
stereoSettingsWidget_->setWindowFlags(Qt::Popup);
// Connect Ok button to local slot
connect(stereoSettingsWidget_->confirmButton, SIGNAL(pressed()),
// Connect combo boxes and sliders to local slots
connect(stereoSettingsWidget_->stereoOpengl, SIGNAL(clicked()),
this, SLOT(slotApplyStereoSettings()));
connect(stereoSettingsWidget_->stereoAnaglyph, SIGNAL(clicked()),
this, SLOT(slotApplyStereoSettings()));
connect(stereoSettingsWidget_->stereoCustomAnaglyph, SIGNAL(clicked()),
this, SLOT(slotApplyStereoSettings()));
connect(stereoSettingsWidget_->stereoPhilips, SIGNAL(clicked()),
this, SLOT(slotApplyStereoSettings()));
connect(stereoSettingsWidget_->focalDistance, SIGNAL(valueChanged(int)),
this, SLOT(slotApplyStereoSettings(int)));
connect(stereoSettingsWidget_->eyeDistance, SIGNAL(editingFinished()),
this, SLOT(slotApplyStereoSettings()));
connect(stereoSettingsWidget_->headerContentType, SIGNAL(currentIndexChanged(int)),
this, SLOT(slotApplyStereoSettings(int)));
connect(stereoSettingsWidget_->headerFactor, SIGNAL(valueChanged(int)),
this, SLOT(slotApplyStereoSettings(int)));
connect(stereoSettingsWidget_->headerOffsetCC, SIGNAL(valueChanged(int)),
this, SLOT(slotApplyStereoSettings(int)));
connect(stereoSettingsWidget_->headerSelect, SIGNAL(currentIndexChanged(int)),
this, SLOT(slotApplyStereoSettings(int)));
// Close button
connect(stereoSettingsWidget_->closeButton, SIGNAL(clicked()),
stereoSettingsWidget_, SLOT(hide()));
}
......
......@@ -811,7 +811,9 @@ public:
void stereoButtonContextMenu(const QPoint& _pos);
/// Is called if the user has changed stereo settings
void slotApplyStereoSettings();
/// Note: The parameter just makes sure, we can connect
/// all necessary signals to this slot. It has no use for now.
void slotApplyStereoSettings(int _tmpParam = 0);
private:
......
......@@ -346,31 +346,69 @@ void CoreWidget::stereoButtonContextMenu(const QPoint& _pos) {
stereoSettingsWidget_->eyeDistance->setValue(OpenFlipper::Options::eyeDistance());
stereoSettingsWidget_->focalDistance->setValue(OpenFlipper::Options::focalDistance() * 1000);
// Philips stereo mode part
stereoSettingsWidget_->headerContentType->setCurrentIndex(OpenFlipper::Options::stereoPhilipsContent());
stereoSettingsWidget_->headerFactor->setValue(OpenFlipper::Options::stereoPhilipsFactor());
stereoSettingsWidget_->headerOffsetCC->setValue(OpenFlipper::Options::stereoPhilipsOffset());
stereoSettingsWidget_->factorCounter->setNum(OpenFlipper::Options::stereoPhilipsFactor());
stereoSettingsWidget_->offsetCounter->setNum(OpenFlipper::Options::stereoPhilipsOffset());
stereoSettingsWidget_->headerSelect->setCurrentIndex(OpenFlipper::Options::stereoPhilipsSelect());
// Default values are strange...
/*
std::cerr << "Content type: " << OpenFlipper::Options::stereoPhilipsContent() << std::endl;
std::cerr << "Factor: " << OpenFlipper::Options::stereoPhilipsFactor() << std::endl;
std::cerr << "Offset: " << OpenFlipper::Options::stereoPhilipsOffset() << std::endl;
std::cerr << "Select: " << OpenFlipper::Options::stereoPhilipsSelect() << std::endl;
*/
// Show right stacked widget
if (stereoSettingsWidget_->stereoPhilips->isChecked()) {
stereoSettingsWidget_->stackedWidget->setCurrentIndex(1);
} else {
stereoSettingsWidget_->stackedWidget->setCurrentIndex(0);
}
// Move widget to the position of the cursor
stereoSettingsWidget_->move(stereoButton_->mapToGlobal(_pos));
stereoSettingsWidget_->move(stereoButton_->mapToGlobal(_pos) - QPoint((int)(stereoSettingsWidget_->width()/2), 0));
// Show widget
stereoSettingsWidget_->show();
}
void CoreWidget::slotApplyStereoSettings() {
// Hide widget
stereoSettingsWidget_->hide();
void CoreWidget::slotApplyStereoSettings(int /*_tmpParam*/) {
// Update values
if (stereoSettingsWidget_->stereoCustomAnaglyph->isChecked()) {
// Update option entry
OpenFlipper::Options::stereoMode(OpenFlipper::Options::AnaglyphCustom);
// Show right stacked widget
stereoSettingsWidget_->stackedWidget->setCurrentIndex(0);
} else if (stereoSettingsWidget_->stereoAnaglyph->isChecked()) {
OpenFlipper::Options::stereoMode(OpenFlipper::Options::AnaglyphRedCyan);
stereoSettingsWidget_->stackedWidget->setCurrentIndex(0);
} else if (stereoSettingsWidget_->stereoPhilips->isChecked()) {
OpenFlipper::Options::stereoMode(OpenFlipper::Options::Philips);
stereoSettingsWidget_->stackedWidget->setCurrentIndex(1);
} else {
OpenFlipper::Options::stereoMode(OpenFlipper::Options::OpenGL);
stereoSettingsWidget_->stackedWidget->setCurrentIndex(0);
}
OpenFlipper::Options::eyeDistance(stereoSettingsWidget_->eyeDistance->value());
OpenFlipper::Options::focalDistance(
(float)stereoSettingsWidget_->focalDistance->value() / 1000);
if(stereoSettingsWidget_->stackedWidget->currentIndex() == 0) {
OpenFlipper::Options::eyeDistance(stereoSettingsWidget_->eyeDistance->value());
OpenFlipper::Options::focalDistance(
(float)stereoSettingsWidget_->focalDistance->value() / 1000);
} else {
// Update labels that display the current values
stereoSettingsWidget_->factorCounter->setNum(stereoSettingsWidget_->headerFactor->value());
stereoSettingsWidget_->offsetCounter->setNum(stereoSettingsWidget_->headerOffsetCC->value());
// Set option entries
OpenFlipper::Options::stereoPhilipsContent(stereoSettingsWidget_->headerContentType->currentIndex());
OpenFlipper::Options::stereoPhilipsFactor(stereoSettingsWidget_->headerFactor->value());
OpenFlipper::Options::stereoPhilipsOffset(stereoSettingsWidget_->headerOffsetCC->value());
OpenFlipper::Options::stereoPhilipsSelect(stereoSettingsWidget_->headerSelect->currentIndex());
}
// Update all views
for (unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i) {
......
......@@ -160,10 +160,10 @@ glViewer::drawScene_glStereo()
void
glViewer::drawScenePhilipsStereo()
{
int vp_l, vp_b, vp_w, vp_h;
glstate_->get_viewport (vp_l, vp_b, vp_w, vp_h);
// ======================================================================================================
// creating a color texture
// ======================================================================================================
......@@ -176,13 +176,13 @@ glViewer::drawScenePhilipsStereo()
GLenum texType = GL_UNSIGNED_BYTE;
GLenum texFilterMode = GL_NEAREST;
glTexImage2D(texTarget, 0, texInternalFormat, vp_w, vp_h, 0, texFormat, texType, NULL);
glTexParameterf(texTarget, GL_TEXTURE_MIN_FILTER, texFilterMode);
glTexParameterf(texTarget, GL_TEXTURE_MAG_FILTER, texFilterMode);
glTexParameterf(texTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(texTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(texTarget, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL);
// ======================================================================================================
// creating an 24-bit depth + 8-bit stencil texture
// ======================================================================================================
......@@ -207,28 +207,28 @@ glViewer::drawScenePhilipsStereo()
// ======================================================================================================
depthStencilTexture.disable();
colorTexture.disable();
// ======================================================================================================
// Render the scene
// ======================================================================================================
glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
drawScene_mono();
// ======================================================================================================
// Copy Scene to Textures
// ======================================================================================================
colorTexture.enable();
colorTexture.bind();
glCopyTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, vp_l, vp_b, vp_w, vp_h);
colorTexture.disable();
depthStencilTexture.enable();
depthStencilTexture.bind();
glCopyTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, vp_l, vp_b, vp_w, vp_h);
depthStencilTexture.disable();
// ======================================================================================================
......@@ -237,22 +237,22 @@ glViewer::drawScenePhilipsStereo()
GLSL::PtrVertexShader vertexShader;
GLSL::PtrFragmentShader fragmentShader;
GLSL::PtrProgram program;
QString vshaderFile = OpenFlipper::Options::shaderDirStr() + QDir::separator() + "Philips/Vertex.glsl";
QString fshaderFile = OpenFlipper::Options::shaderDirStr() + QDir::separator() + "Philips/Fragment42.glsl";
////
vertexShader = GLSL::loadVertexShader( vshaderFile.toStdString().c_str() );
fragmentShader = GLSL::loadFragmentShader( fshaderFile.toStdString().c_str() );
program = GLSL::PtrProgram(new GLSL::Program());
if ( (vertexShader == 0) ||
(fragmentShader == 0) ||
(program == 0) ) {
std::cerr << "Unable to load shaders for philips display rendering!";
return;
}
program->attach(vertexShader);
program->attach(fragmentShader);
program->link();
......@@ -262,26 +262,26 @@ glViewer::drawScenePhilipsStereo()
// Bind textures to different texture units and tell shader where to find them
// ======================================================================================================
glActiveTextureARB(GL_TEXTURE0_ARB);
colorTexture.enable();
colorTexture.bind();
colorTexture.enable();
colorTexture.bind();
glActiveTextureARB(GL_TEXTURE1_ARB);
depthStencilTexture.enable();
depthStencilTexture.bind();
depthStencilTexture.enable();
depthStencilTexture.bind();
program->setUniform("ColorTexture",0);
program->setUniform("DepthStencil",1);
// ======================================================================================================
// Render plain textured
// Render plain textured
// ======================================================================================================
glDisable(GL_LIGHTING);
glDisable(GL_COLOR_MATERIAL);
glDisable(GL_DEPTH_TEST);
// ======================================================================================================
// Setup orthogonal projection
// ======================================================================================================
......@@ -298,7 +298,7 @@ glViewer::drawScenePhilipsStereo()
// Bind textures to different texture units and tell shader where to find them
// ======================================================================================================
glColor3f(1.0,1.0,1.0);
// ======================================================================================================
// Clear buffers
// ======================================================================================================
......@@ -314,13 +314,13 @@ glViewer::drawScenePhilipsStereo()
glTexCoord2f(1.0f, 0.0f); glVertex2i( vp_w, 0);
glTexCoord2f(0.0f, 0.0f); glVertex2i( 0, 0);
glEnd();
program->disable();
glBindTexture(GL_TEXTURE_2D, 0);
// ======================================================================================================
// Cleanup (color and depth textures)
// Cleanup (color and depth textures)
// ======================================================================================================
depthStencilTexture.del();
colorTexture.del();
......@@ -333,7 +333,7 @@ glViewer::drawScenePhilipsStereo()
// Header ID
// Basic identifier used by the display to verify the header
header[0] = 241; // Header_ID1 = 11110001
// Header content type
// This entry controls the displays internal rendering based on the input data specified here.
// There is no info about how this changes the rendering
......@@ -344,8 +344,8 @@ glViewer::drawScenePhilipsStereo()
// 3 Game
// 4 CGI
// 5 Still
header[1] = 3; // Hdr_Content_type (Game) = 00000011 (Gaming Mode)
header[1] = OpenFlipper::Options::stereoPhilipsContent(); // Hdr_Content_type (Game) = 00000011 (Gaming Mode)
// Header Factor
// Each 3D Display has a 'Display recommended depth value', which corresponds to an
// acceptable maximum depth factor value for that specific type of display. This value strongly
......@@ -355,8 +355,8 @@ glViewer::drawScenePhilipsStereo()
// works on a linear scale and is multiplied with the factor controlled by the user in the Display
// Control Tool.
// Value range: 0-255 (default 64)
header[2] = 64; // Hdr_Factor
header[2] = OpenFlipper::Options::stereoPhilipsFactor(); // Hdr_Factor
// Header Offset CC
// Values in the Depth map equal to the header-offset value will be located on the plane of the
// display. All values in the disparity map with a higher value will de displayed in front of the
......@@ -364,8 +364,8 @@ glViewer::drawScenePhilipsStereo()
// Offset_CC is the offset controlled by the Content Creator. In the system there is also an
// Offset_user present, which is controlled by the user using the Display Control Tool.
// Value Range: 0-255 (default 128)
header[3] = 128; // Hdr_Offset_CC
header[3] = OpenFlipper::Options::stereoPhilipsOffset(); // Hdr_Offset_CC
// Header select
// When all select signals are low the rendering settings are set to optimal settings for the content
// type denoted by Hdr_content_type. By making select signals high the settings for Factor and
......@@ -375,8 +375,8 @@ glViewer::drawScenePhilipsStereo()
// 1 Use Header provided factor
// 2 Use Header provided offset
// 3 Use both factor and offset
header[4] = 0; // Hdr_Factor_select(1) + Hdr_Offset_select(1) + reserved(6)
header[4] = OpenFlipper::Options::stereoPhilipsSelect(); // Hdr_Factor_select(1) + Hdr_Offset_select(1) + reserved(6)
// Unused Header entry (leave at 0 !)
header[5] = 0; // Reserved
......@@ -392,14 +392,14 @@ glViewer::drawScenePhilipsStereo()
// For all bytes of the header
for (int i = 0; i < 6; i++) {
// For each bit of a headers byte
for ( int j = 7 ; j >= 0 ; --j ) {
// Red and Green component have to be 0
bitVector.push_back(0);
bitVector.push_back(0);
// If bit is set, the full component will be set to one otherwise zero
// And the order of the bits has to be reversed!
if ( header[i] & (1 << j ) ) {
......@@ -407,32 +407,32 @@ glViewer::drawScenePhilipsStereo()
} else {
bitVector.push_back(0);
}
// Only every second pixel is used for the header
// Skip every odd one by filling in 0 for RGB
bitVector.push_back(0);
bitVector.push_back(0);
bitVector.push_back(0);
}
}
// Append checksum to header.
// Append checksum to header.
// Reversed bit order!
for (int i=31; i >= 0; i--) {
// Red and Green component have to be 0
bitVector.push_back(0);
bitVector.push_back(0);
if ( checksum & (1 << i ) )
bitVector.push_back( 255 );
else
bitVector.push_back( 0 );
// Only every second pixel is used for the header
// Skip every odd one by filling in 0 for RGB
// Skip every odd one by filling in 0 for RGB
bitVector.push_back(0);
bitVector.push_back(0);
bitVector.push_back(0);
......@@ -441,12 +441,12 @@ glViewer::drawScenePhilipsStereo()
// Select the top left of the renderbuffer and
// write complete header into these bits
glRasterPos2i (0,glHeight()-1);
glRasterPos2i (0,glHeight()-1);
glDrawPixels(bitVector.size()/3, 1,GL_RGB ,GL_UNSIGNED_BYTE , &bitVector[0]);
// ======================================================================================================
// Reset projection and modelview
// ======================================================================================================
// ======================================================================================================
glstate_->pop_projection_matrix();
glstate_->pop_modelview_matrix();
......@@ -496,7 +496,7 @@ glViewer::drawScene_anaglyphStereo()
drawScene_mono();
glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);
// right eye
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
......@@ -692,7 +692,7 @@ glViewer::drawScene_customAnaglyphStereo()
glBindProgramARB (GL_FRAGMENT_PROGRAM_ARB, 0);
glDisable (GL_FRAGMENT_PROGRAM_ARB);
glActiveTexture (GL_TEXTURE1);
glBindTexture (GL_TEXTURE_RECTANGLE_NV, 0);
glDisable (GL_TEXTURE_RECTANGLE_NV);
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>496</width>
<height>304</height>
<width>427</width>
<height>362</height>
</rect>
</property>
<property name="windowTitle">
......@@ -19,7 +19,7 @@
<property name="title">
<string>Stereo Mode</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_14">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QRadioButton" name="stereoOpengl">
<property name="text">
......@@ -44,178 +44,375 @@
<item>
<widget class="QRadioButton" name="stereoPhilips">
<property name="text">
<string>Philips Stereo Mode (For 3D autostereoskopic displays)</string>
<string>Philips Stereo Mode (For 3D autostereoscopic displays)</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_7">
<property name="title">
<string>View properties</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_15">
<item>
<layout class="QVBoxLayout" name="verticalLayout_18">
<item>
<widget class="QLabel" name="label_11">
<property name="text">
<string>Eye distance:</string>
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="page">
<widget class="QGroupBox" name="groupBox_7">
<property name="geometry">
<rect>
<x>0</x>
<y>20</y>
<width>381</width>
<height>101</height>
</rect>
</property>
<property name="title">
<string>View properties</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_15">
<item>
<layout class="QVBoxLayout" name="verticalLayout_18">
<item>
<widget class="QLabel" name="label_11">
<property name="text">
<string>Eye distance:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_12">
<property name="text">
<string>Focal distance:</string>
</property>