Commit bec90bfc authored by Jan Möbius's avatar Jan Möbius

Moved two sided lighting, animation and backface culling to viewer properties

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@4522 383ad7c9-94d9-4d36-a494-682f7c89f535
parent fda868d6
......@@ -430,9 +430,9 @@ void Core::writeApplicationOptions(INIFile& _ini) {
std::cerr << "Todo : Save application options for multiple views" << std::endl;
}
_ini.add_entry("Options","BackfaceCulling",coreWidget_->examiner_widgets_[0]->backFaceCulling());
_ini.add_entry("Options","Animation",coreWidget_->examiner_widgets_[0]->animation());
_ini.add_entry("Options","twoSidedLighting",coreWidget_->examiner_widgets_[0]->twoSidedLighting());
_ini.add_entry("Options","BackfaceCulling",PluginFunctions::viewerProperties().backFaceCulling());
_ini.add_entry("Options","Animation",PluginFunctions::viewerProperties().animation());
_ini.add_entry("Options","twoSidedLighting",PluginFunctions::viewerProperties().twoSidedLighting());
_ini.add_entry("Options","WheelZoomFactor",coreWidget_->examiner_widgets_[0]->wheelZoomFactor());
_ini.add_entry("Options","WheelZoomFactorShift",coreWidget_->examiner_widgets_[0]->wheelZoomFactorShift());
......
......@@ -90,10 +90,10 @@ void Core::applyOptions(){
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
//animation
coreWidget_->examiner_widgets_[i]->animation(OpenFlipper::Options::animation());
PluginFunctions::viewerProperties(i).animation(OpenFlipper::Options::animation());
//Backface Culling
coreWidget_->examiner_widgets_[i]->backFaceCulling(OpenFlipper::Options::backfaceCulling());
PluginFunctions::viewerProperties(i).backFaceCulling(OpenFlipper::Options::backfaceCulling());
//wheel zoom factor
coreWidget_->examiner_widgets_[i]->setWheelZoomFactor(OpenFlipper::Options::wheelZoomFactor());
......
......@@ -54,6 +54,9 @@ namespace Viewer {
renderPicking_(false),
pickRendererMode_(ACG::SceneGraph::PICK_ANYTHING),
locked_(0),
backFaceCulling_(false),
twoSidedLighting_(true),
animation_(false),
glState_(0)
{
......
......@@ -231,6 +231,43 @@ namespace Viewer {
private:
int locked_;
//===========================================================================
public slots:
/// Get current state of backface culling
bool backFaceCulling() { return backFaceCulling_; };
/// Enable or disable backface culling
void backFaceCulling(bool _state ) { backFaceCulling_ = _state; emit updated(); }
private:
bool backFaceCulling_;
//===========================================================================
public slots:
/// set 2-sided lighting on/off
void twoSidedLighting(bool _state ) { twoSidedLighting_ = _state; glState_->set_twosided_lighting( _state ); emit updated(); }
/// is 2-sided lighing enabled?
bool twoSidedLighting() { return twoSidedLighting_; };
private:
bool twoSidedLighting_;
//===========================================================================
public slots:
/// set 2-sided lighting on/off
void animation(bool _state ) { animation_ = _state; emit updated(); }
/// is 2-sided lighing enabled?
bool animation() { return animation_; };
private:
bool animation_;
//===========================================================================
public:
......
......@@ -256,8 +256,8 @@ void CoreWidget::updatePopupMenu(const QPoint& _point, unsigned int _examinerId)
action->setCheckable( true );
action->setChecked( OpenFlipper::Options::animation() );
for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
connect(action, SIGNAL(triggered(bool)), examiner_widgets_[i], SLOT(animation(bool)) );
connect(action, SIGNAL(triggered(bool)), this, SLOT(updateGlobalOptions(bool)) );
connect(action, SIGNAL(triggered(bool)), &(PluginFunctions::viewerProperties(i)), SLOT(animation(bool)) );
connect(action, SIGNAL(triggered(bool)), this, SLOT(updateGlobalOptions()) );
//====================================================================================================
......@@ -266,8 +266,8 @@ void CoreWidget::updatePopupMenu(const QPoint& _point, unsigned int _examinerId)
action->setCheckable( true );
action->setChecked( OpenFlipper::Options::backfaceCulling() );
for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
connect(action, SIGNAL(triggered(bool)), examiner_widgets_[i], SLOT(backFaceCulling(bool)) );
connect(action, SIGNAL(triggered(bool)), this, SLOT(updateGlobalOptions(bool)) );
connect(action, SIGNAL(triggered(bool)), &(PluginFunctions::viewerProperties(i)), SLOT(backFaceCulling(bool)) );
connect(action, SIGNAL(triggered(bool)), this, SLOT(updateGlobalOptions()) );
//====================================================================================================
......@@ -276,10 +276,14 @@ void CoreWidget::updatePopupMenu(const QPoint& _point, unsigned int _examinerId)
action->setCheckable( true );
action->setChecked( OpenFlipper::Options::twoSidedLighting() );
for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
connect(action, SIGNAL(triggered(bool)), examiner_widgets_[i], SLOT(twoSidedLighting(bool)) );
connect(action, SIGNAL(triggered(bool)), this, SLOT(updateGlobalOptions(bool)) );
connect(action, SIGNAL(triggered(bool)), &(PluginFunctions::viewerProperties(i)) , SLOT(twoSidedLighting(bool)) );
connect(action, SIGNAL(triggered(bool)), this, SLOT(updateGlobalOptions()) );
functionMenu_->setTearOffEnabled(true);
for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets(); ++i )
connect( &(PluginFunctions::viewerProperties(i)) , SIGNAL(updated()) , this, SLOT(updateGlobalOptions()));
}
contextMenu_->addMenu(functionMenu_ );
......@@ -354,10 +358,10 @@ void CoreWidget::slotCopyView( ) {
examiner_widgets_[PluginFunctions::activeExaminer()]->actionCopyView();
}
void CoreWidget::updateGlobalOptions(bool /*_enable*/){
OpenFlipper::Options::animation( examiner_widgets_[0]->animation() );
OpenFlipper::Options::backfaceCulling( examiner_widgets_[0]->backFaceCulling() );
OpenFlipper::Options::twoSidedLighting( examiner_widgets_[0]->twoSidedLighting() );
void CoreWidget::updateGlobalOptions(){
OpenFlipper::Options::animation( PluginFunctions::viewerProperties().animation() );
OpenFlipper::Options::backfaceCulling( PluginFunctions::viewerProperties().backFaceCulling() );
OpenFlipper::Options::twoSidedLighting( PluginFunctions::viewerProperties().twoSidedLighting() );
}
void CoreWidget::slotAddContextMenu(QMenu* _menu) {
......
......@@ -442,7 +442,7 @@ public:
void slotAddContextMenu( QMenu* _menu , DataType _dataType ,ContextMenuType type_);
/// update globalOptions for actions in the contexMenu
void updateGlobalOptions(bool _enable);
void updateGlobalOptions();
/// change the background color
void changeBackgroundColor();
......
......@@ -122,11 +122,11 @@ void CoreWidget::slotFunctionMenuUpdate() {
for ( int i = 0 ; i < allActions.size(); ++i ) {
if ( allActions[i]->text() == "Animation" )
allActions[i]->setChecked(examiner_widgets_[0]->animation());
allActions[i]->setChecked(PluginFunctions::viewerProperties().animation());
else if ( allActions[i]->text() == "Backface Culling" )
allActions[i]->setChecked(examiner_widgets_[0]->backFaceCulling());
allActions[i]->setChecked(PluginFunctions::viewerProperties().backFaceCulling());
else if ( allActions[i]->text() == "Two-sided Lighting" )
allActions[i]->setChecked(examiner_widgets_[0]->twoSidedLighting());
allActions[i]->setChecked(PluginFunctions::viewerProperties().twoSidedLighting());
}
}
......
......@@ -132,17 +132,13 @@ glViewer::glViewer( QWidget* _parent,
exit(1);
}
// widget stuff
createWidgets(_format,_statusBar,_share);
// bind GL context to GL state class
glstate_ = new ACG::GLState();
properties_.setglState( glstate_ );
// state
orthoWidth_ = 2.0;
isRotating_ = false;
......@@ -159,9 +155,7 @@ glViewer::glViewer( QWidget* _parent,
normalsMode_ = DONT_TOUCH_NORMALS;
projectionMode_ = PERSPECTIVE_PROJECTION;
backFaceCulling_ = false;
twoSidedLighting_ = true;
animation_ = false;
light_matrix_.identity();
......@@ -449,43 +443,6 @@ void glViewer::updateActionMode(Viewer::ActionMode _am)
//-----------------------------------------------------------------------------
void glViewer::backFaceCulling(bool _b)
{
emit functionMenuUpdate();
makeCurrent();
if ( (backFaceCulling_ = _b) )
glEnable( GL_CULL_FACE );
else
glDisable( GL_CULL_FACE );
updateGL();
}
void glViewer::twoSidedLighting(bool _b)
{
emit functionMenuUpdate();
makeCurrent();
glstate_->set_twosided_lighting(twoSidedLighting_=_b);
updateGL();
}
void glViewer::animation(bool _b)
{
emit functionMenuUpdate();
makeCurrent();
animation_ = _b;
updateGL();
}
//-----------------------------------------------------------------------------
void glViewer::normalsMode(NormalsMode _mode)
{
makeCurrent();
......@@ -871,8 +828,6 @@ void glViewer::initializeGL()
projectionMode( projectionMode_ );
normalsMode( normalsMode_ );
backFaceCulling( backFaceCulling_ );
twoSidedLighting( twoSidedLighting_ );
// Update all settings which would require a redraw
applyProperties();
......@@ -1017,7 +972,6 @@ void glViewer::paintGL()
normalsMode( normalsMode_ );
backFaceCulling( backFaceCulling_ );
applyProperties();
......@@ -1317,13 +1271,6 @@ glViewer::createWidgets(const QGLFormat* _format,
std::cerr << "Stereo buffer requested: "
<< (glWidget_->format().stereo() ? "ok\n" : "failed\n");
glLayout_ = new QGridLayout(work);
glLayout_->setSpacing( 0 );
glLayout_->setMargin( 0 );
......@@ -1896,8 +1843,7 @@ glViewer::viewMouseEvent(QMouseEvent* _event)
if ( isRotating_ &&
(_event->button() == Qt::LeftButton) &&
(!(_event->buttons() & Qt::MidButton)) &&
(lastMoveTime_.elapsed() < 10) &&
animation() )
(lastMoveTime_.elapsed() < 10) && properties_.animation() )
timer_->start(0);
break;
}
......@@ -2091,6 +2037,13 @@ void glViewer::applyProperties() {
glFrontFace( GL_CCW );
else
glFrontFace( GL_CW );
if ( properties_.backFaceCulling() )
glEnable( GL_CULL_FACE );
else
glDisable( GL_CULL_FACE );
}
void glViewer::slotPropertiesUpdated() {
......
......@@ -159,13 +159,6 @@ public:
/// Unlock update of projection matrix.
void unlockProjectionUpdate( void ) { projectionUpdateLocked_ = false; }
/// Is animation enabled?
bool animation() const { return animation_; }
public slots:
/// Set animation enabled.
void animation(bool _b);
signals :
void functionMenuUpdate();
......@@ -214,24 +207,6 @@ public:
/// set the viewing direction
void viewingDirection( const ACG::Vec3d& _dir, const ACG::Vec3d& _up );
public:
public slots:
/// set backface culling on/off
void backFaceCulling( bool _b );
public:
/// is backface culling enabled?
bool backFaceCulling() const { return backFaceCulling_; }
public slots:
/// set 2-sided lighting on/off
void twoSidedLighting( bool _b );
public:
/// is 2-sided lighing enabled?
bool twoSidedLighting() const { return twoSidedLighting_; }
/// Automatically normalize normals?
enum NormalsMode {
/// use provided normals as is
......@@ -569,9 +544,7 @@ private:
// modi
NormalsMode normalsMode_;
ProjectionMode projectionMode_;
bool backFaceCulling_;
bool twoSidedLighting_;
bool animation_;
// helper
bool trackMouse_;
......
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