From 713e6b486335944a9533818f258fb651594d5bd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= <moebius@cs.rwth-aachen.de> Date: Thu, 29 Jan 2009 10:57:10 +0000 Subject: [PATCH] moved face orientation setting to viewer properties git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@4514 383ad7c9-94d9-4d36-a494-682f7c89f535 --- common/ViewerProperties.cc | 3 ++- common/ViewerProperties.hh | 18 ++++++++++++++++ widgets/glWidget/QtBaseViewer.cc | 37 +++++++++++--------------------- widgets/glWidget/QtBaseViewer.hh | 13 ----------- 4 files changed, 33 insertions(+), 38 deletions(-) diff --git a/common/ViewerProperties.cc b/common/ViewerProperties.cc index e44b9f22..b2c146dd 100644 --- a/common/ViewerProperties.cc +++ b/common/ViewerProperties.cc @@ -48,7 +48,8 @@ namespace Viewer { actionMode_(Viewer::PickingMode), lastActionMode_(Viewer::PickingMode), snapshotName_("snap.png"), - snapshotCounter_(0) + snapshotCounter_(0), + CCWFront_(true) { } diff --git a/common/ViewerProperties.hh b/common/ViewerProperties.hh index cc16341d..4ea12d0b 100644 --- a/common/ViewerProperties.hh +++ b/common/ViewerProperties.hh @@ -135,6 +135,24 @@ namespace Viewer { /** @} */ + //=========================================================================== + /** @name Rendering Settings + * @{ */ + //=========================================================================== + public slots: + /** true if counter clockwise orientation should be used to define front facing orientation. + */ + bool isCCWFront(){ return CCWFront_; }; + + /// Set counter clockwise orientation as front + void ccwFront() { CCWFront_ = true; emit updated(); }; + /// Set clockwise orientation as front + void cwFront() { CCWFront_ = false; emit updated(); }; + + private: + bool CCWFront_; + + /** @} */ signals: /** \brief This signal is emitted when the configuration has been changed diff --git a/widgets/glWidget/QtBaseViewer.cc b/widgets/glWidget/QtBaseViewer.cc index 46393d0f..bad50837 100644 --- a/widgets/glWidget/QtBaseViewer.cc +++ b/widgets/glWidget/QtBaseViewer.cc @@ -158,7 +158,6 @@ glViewer::glViewer( QWidget* _parent, availDrawModes_ = ACG::SceneGraph::DrawModes::NONE; normalsMode_ = DONT_TOUCH_NORMALS; - faceOrientation_ = CCW_ORIENTATION; projectionMode_ = PERSPECTIVE_PROJECTION; backFaceCulling_ = false; twoSidedLighting_ = true; @@ -480,27 +479,6 @@ void glViewer::updateActionMode(Viewer::ActionMode _am) //----------------------------------------------------------------------------- -void glViewer::faceOrientation(FaceOrientation _ori) -{ - makeCurrent(); - - switch ( faceOrientation_ = _ori ) { - case CCW_ORIENTATION: - glFrontFace( GL_CCW ); - break; - - case CW_ORIENTATION: - glFrontFace( GL_CW ); - break; - } - - updateGL(); -} - - -//----------------------------------------------------------------------------- - - void glViewer::backFaceCulling(bool _b) { emit functionMenuUpdate(); @@ -930,10 +908,11 @@ void glViewer::initializeGL() projectionMode( projectionMode_ ); normalsMode( normalsMode_ ); - faceOrientation( faceOrientation_ ); backFaceCulling( backFaceCulling_ ); twoSidedLighting( twoSidedLighting_ ); + // Update all settings which would require a redraw + slotPropertiesUpdated(); // light sources light_matrix_.identity(); @@ -1082,9 +1061,10 @@ void glViewer::paintGL() normalsMode( normalsMode_ ); - faceOrientation( faceOrientation_ ); backFaceCulling( backFaceCulling_ ); + slotPropertiesUpdated(); + // light sources update_lights(); @@ -2160,6 +2140,15 @@ void glViewer::slotAnimation() void glViewer::slotPropertiesUpdated() { std::cerr << "glViewer : Properties updated" << std::endl; + + makeCurrent(); + + if (properties_.isCCWFront() ) + glFrontFace( GL_CCW ); + else + glFrontFace( GL_CW ); + + updateGL(); } diff --git a/widgets/glWidget/QtBaseViewer.hh b/widgets/glWidget/QtBaseViewer.hh index c2a81d10..3202952b 100644 --- a/widgets/glWidget/QtBaseViewer.hh +++ b/widgets/glWidget/QtBaseViewer.hh @@ -249,18 +249,6 @@ public: public: - - /// orientation of the faces - enum FaceOrientation { - CCW_ORIENTATION, //!< counter clockwise (default) - CW_ORIENTATION //!< clockwise - }; - - /// set face orientation (used for back face culling, backFaceCulling()) - void faceOrientation(FaceOrientation); - /// get face orientation - FaceOrientation faceOrientation() const { return faceOrientation_; } - public slots: /// set backface culling on/off void backFaceCulling( bool _b ); @@ -626,7 +614,6 @@ private: // modi NormalsMode normalsMode_; - FaceOrientation faceOrientation_; ProjectionMode projectionMode_; bool backFaceCulling_; bool twoSidedLighting_; -- GitLab