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

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