Commit 05439ad5 authored by Jan Möbius's avatar Jan Möbius

Made DrawMode an extra class

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@8548 383ad7c9-94d9-4d36-a494-682f7c89f535
parent bc546846
......@@ -1469,7 +1469,7 @@ bool QtBaseViewer::decodeView(const QString& _view)
void QtBaseViewer::actionDrawMenu( QAction * _action )
{
unsigned int mode( _action->data().toUInt() );
SceneGraph::DrawModes::DrawMode mode( _action->data().toUInt() );
// combine draw modes
if (qApp->keyboardModifiers() & Qt::ShiftModifier)
......@@ -1491,7 +1491,7 @@ void QtBaseViewer::actionDrawMenu( QAction * _action )
aIter != aEnd;
++aIter )
{
if( (*aIter)->data().toUInt() != mode )
if( SceneGraph::DrawModes::DrawMode((*aIter)->data().toUInt()) != mode )
(*aIter)->setChecked( false );
}
......@@ -1941,19 +1941,19 @@ void QtBaseViewer::updatePopupMenu()
drawMenuActions_.clear();
std::vector< unsigned int > draw_mode_id;
std::vector< SceneGraph::DrawModes::DrawMode > draw_mode_id;
draw_mode_id = SceneGraph::DrawModes::getDrawModeIDs( availDrawModes_ );
draw_mode_id = availDrawModes_.getAtomicDrawModes();
for ( unsigned int i = 0; i < draw_mode_id.size(); ++i )
{
unsigned int id = draw_mode_id[i];
std::string descr = SceneGraph::DrawModes::description( id );
SceneGraph::DrawModes::DrawMode id = draw_mode_id[i];
std::string descr = id.description();
QAction * action = new QAction( descr.c_str(), drawGroup );
action->setData( QVariant( id ) );
action->setData( QVariant( id.getIndex() ) );
action->setCheckable( true );
action->setChecked( SceneGraph::DrawModes::containsId( curDrawMode_, id ) );
action->setChecked( curDrawMode_.containsAtomicDrawMode(id) );
drawMenuActions_.push_back( action );
}
......
......@@ -56,6 +56,7 @@
#include "../GL/GLState.hh"
#include "../Scenegraph/SceneGraph.hh"
#include "../Scenegraph/DrawModes.hh"
#include <QtOpenGL/QGLFormat>
#include <QBoxLayout>
......@@ -442,14 +443,14 @@ public:
/// set draw mode (No test if this mode is available!)
void drawMode(unsigned int _mode)
void drawMode(ACG::SceneGraph::DrawModes::DrawMode _mode)
{
curDrawMode_=_mode;
updatePopupMenu();
}
/// get current draw mode
unsigned int drawMode() { return curDrawMode_; }
ACG::SceneGraph::DrawModes::DrawMode drawMode() { return curDrawMode_; }
/// convert current view to text representation
void encodeView(QString& _view);
......@@ -820,8 +821,8 @@ private:
// scenegraph stuff
SceneGraph::BaseNode* sceneGraphRoot_;
unsigned int curDrawMode_,
availDrawModes_;
ACG::SceneGraph::DrawModes::DrawMode curDrawMode_,
availDrawModes_;
bool updateLocked_;
bool projectionUpdateLocked_;
......
......@@ -92,16 +92,6 @@ namespace QtWidgets {
//== IMPLEMENTATION ==========================================================
enum PopupMenuItems
{
M_Options = SceneGraph::DrawModes::UNUSED+1
};
//-----------------------------------------------------------------------------
QtSceneGraphWidget::
QtSceneGraphWidget( QWidget * _parent,
SceneGraph::BaseNode * _rootNode ) :
......@@ -289,25 +279,23 @@ slotItemPressed( QTreeWidgetItem * _item,
connect( modeGroup, SIGNAL( triggered( QAction * ) ),
this, SLOT( slotModeMenu( QAction * ) ) );
unsigned int availDrawModes( node->availableDrawModes() );
ACG::SceneGraph::DrawModes::DrawMode availDrawModes( node->availableDrawModes() );
availDrawModes |= SceneGraph::DrawModes::DEFAULT;
unsigned int currentDrawMode( node->drawMode() );
ACG::SceneGraph::DrawModes::DrawMode currentDrawMode( node->drawMode() );
std::vector< unsigned int > available_modes
( SceneGraph::DrawModes::getDrawModeIDs( availDrawModes ) );
std::vector< ACG::SceneGraph::DrawModes::DrawMode > available_modes( availDrawModes.getAtomicDrawModes() );
for ( unsigned int i = 0; i < available_modes.size(); ++i )
{
unsigned int id = available_modes[i];
std::string descr = SceneGraph::DrawModes::description( id );
ACG::SceneGraph::DrawModes::DrawMode id = available_modes[i];
std::string descr = id.description();
QAction * action = new QAction( descr.c_str(), modeGroup );
action->setCheckable( true );
action->setChecked
( SceneGraph::DrawModes::containsId( currentDrawMode, id ) );
action->setData( QVariant( id ) );
action->setChecked ( currentDrawMode.containsAtomicDrawMode(id ) ) ;
action->setData( QVariant( id.getIndex() ) );
}
modeMenu_->addActions( modeGroup->actions() );
......@@ -446,14 +434,8 @@ void QtSceneGraphWidget::slotEditCoordinateFrame()
void QtSceneGraphWidget::slotModeMenu( QAction * _action )
{
unsigned int id = _action->data().toUInt();
SceneGraph::DrawModes::DrawMode new_drawmode( _action->data().toUInt());
// int old_drawmode = curItem_->node()->drawMode();
int new_drawmode = id;
// if (shiftPressed_)
// new_drawmode ^= (old_drawmode & 0xFFFE);
curItem_->node()->drawMode( new_drawmode );
curItem_->update();
emit signalNodeChanged( curItem_->node() );
......@@ -552,7 +534,7 @@ QtSceneGraphWidget::Item::update()
case BaseNode::HideSubtree: setText( 2, "HideSubtree"); break;
}
setText( 3, SceneGraph::DrawModes::description(node_->drawMode()).c_str());
setText( 3, node_->drawMode().description().c_str());
}
......
......@@ -74,12 +74,12 @@ QtShaderDialog::QtShaderDialog( QWidget * _parent,
{
ui_.setupUi( this );
unsigned int drawmode = ACG::SceneGraph::DrawModes::DEFAULT;
ACG::SceneGraph::DrawModes::DrawMode drawmode = ACG::SceneGraph::DrawModes::DEFAULT;
while ( drawmode != ACG::SceneGraph::DrawModes::UNUSED )
{
ui_.drawModeBox->addItem( QString(ACG::SceneGraph::DrawModes::description(drawmode).c_str() ));
drawmode *= 2 ;
ui_.drawModeBox->addItem( QString( drawmode.description().c_str() ) );
++drawmode ;
}
ui_.shaderDir->setText( QString(_node->shaderDir().c_str()) );
......
......@@ -173,7 +173,7 @@ BaseNode::delete_subtree()
//----------------------------------------------------------------------------
void
BaseNode::enterPick(GLState& _state, PickTarget /*_target*/, unsigned int _drawMode)
BaseNode::enterPick(GLState& _state, PickTarget /*_target*/, DrawModes::DrawMode _drawMode)
{
enter (_state, _drawMode);
}
......@@ -181,7 +181,7 @@ BaseNode::enterPick(GLState& _state, PickTarget /*_target*/, unsigned int _drawM
//----------------------------------------------------------------------------
void
BaseNode::leavePick(GLState& _state, PickTarget /*_target*/, unsigned int _drawMode)
BaseNode::leavePick(GLState& _state, PickTarget /*_target*/, DrawModes::DrawMode _drawMode)
{
leave (_state, _drawMode);
}
......
......@@ -69,6 +69,7 @@
#include <string>
#include <algorithm>
#include <iostream>
#include <ACG/Scenegraph/DrawModes.hh>
//== NAMESPACES ===============================================================
......@@ -147,7 +148,7 @@ public:
/** Return a list of available draw modes for this node: should be OR'ed
from the items of the enum DrawModeIDs. */
virtual unsigned int availableDrawModes() const { return 0; }
virtual DrawModes::DrawMode availableDrawModes() const { return DrawModes::NONE; }
/** Compute the bounding box of this node and update the values
_bbMin and _bbMax accordingly. Do not initialize _bbMin and
......@@ -162,15 +163,15 @@ public:
function.
\see MaterialNode
*/
virtual void enter(GLState& /*_state */, unsigned int /*_drawMode*/ ) {}
virtual void enter(GLState& /*_state */, DrawModes::DrawMode /*_drawMode*/ ) {}
/** Draw this node using the draw modes _drawMode */
virtual void draw(GLState& /* _state */, unsigned int /* _drawMode */) {}
virtual void draw(GLState& /* _state */, DrawModes::DrawMode /* _drawMode */) {}
/** The leave function is used to restore GL states the have been changed.
This function must restore the status before enter() !
*/
virtual void leave(GLState& /* _state */, unsigned int /* _drawMode */) {}
virtual void leave(GLState& /* _state */, DrawModes::DrawMode /* _drawMode */) {}
/** This function is called when traversing the scene graph during picking
and arriving at this node. It can be used to store GL states that
......@@ -178,7 +179,7 @@ public:
function. Its default implementation will call the enter() function.
*/
virtual void enterPick(GLState& _state , PickTarget _target,
unsigned int _drawMode );
DrawModes::DrawMode _drawMode );
/** Draw the node using the GL picking name stack. The node's ID
will already be on the name stack, so only names identifing e.g. faces
......@@ -191,7 +192,7 @@ public:
Its default implementation will call the leave() function.
*/
virtual void leavePick(GLState& _state, PickTarget _target,
unsigned int _drawMode );
DrawModes::DrawMode _drawMode );
/** Enable or Disable picking for this node
* ( default: enabled )
......@@ -365,10 +366,10 @@ public:
//--- draw mode ---
/// Return the own draw modes of this node
unsigned int drawMode() const { return drawMode_; }
DrawModes::DrawMode drawMode() const { return drawMode_; }
/** Set this node's own draw mode. It will be used for drawing instead of
the the global draw mode. */
void drawMode(unsigned int _drawMode) { drawMode_ = _drawMode; }
void drawMode(DrawModes::DrawMode _drawMode) { drawMode_ = _drawMode; }
//--- traverse type ---
......@@ -550,7 +551,7 @@ private:
unsigned int id_;
/// private draw mode
unsigned int drawMode_;
DrawModes::DrawMode drawMode_;
/// depth func
GLenum depth_func_;
......
......@@ -63,7 +63,7 @@ namespace SceneGraph {
//== IMPLEMENTATION ==========================================================
unsigned int
DrawModes::DrawMode
BoundingBoxNode::
availableDrawModes() const
{
......@@ -79,7 +79,7 @@ BoundingBoxNode::~BoundingBoxNode() {
void
BoundingBoxNode::
draw(GLState& /* _state */ , unsigned int _drawMode)
draw(GLState& /* _state */ , DrawModes::DrawMode _drawMode)
{
ACG::SceneGraph::BoundingBoxAction act;
......
......@@ -96,10 +96,10 @@ public:
ACG_CLASSNAME(BoundingBoxNode);
/// return available draw modes
unsigned int availableDrawModes() const;
DrawModes::DrawMode availableDrawModes() const;
/// draw lines and normals
void draw(GLState& _state, unsigned int _drawMode);
void draw(GLState& _state, DrawModes::DrawMode _drawMode);
};
......
......@@ -67,7 +67,7 @@ CartesianClippingNode::CartesianClippingNode( BaseNode* _parent,
void
CartesianClippingNode::enter( GLState & _state, unsigned int /* _drawmode */ )
CartesianClippingNode::enter( GLState & _state, DrawModes::DrawMode /* _drawmode */ )
{
Vec3d eye = _state.eye();
......@@ -146,7 +146,7 @@ CartesianClippingNode::enter( GLState & _state, unsigned int /* _drawmode */ )
void
CartesianClippingNode::leave( GLState & /* _state */ , unsigned int /* _drawmode */ )
CartesianClippingNode::leave( GLState & /* _state */ , DrawModes::DrawMode /* _drawmode */ )
{
glDisable( GL_CLIP_PLANE0 );
glDisable( GL_CLIP_PLANE1 );
......
......@@ -87,10 +87,10 @@ public:
ACG_CLASSNAME(CartesianClippingNode);
/// begin clipping
void enter( GLState & _state, unsigned int _drawmode );
void enter( GLState & _state, DrawModes::DrawMode _drawmode );
/// stop clipping
void leave( GLState & _state, unsigned int _drawmode );
void leave( GLState & _state, DrawModes::DrawMode _drawmode );
/// set position
void set_cursor( const Vec3f & _pos );
......
......@@ -133,7 +133,7 @@ ClippingNode::set_offset(float _offset)
//----------------------------------------------------------------------------
void ClippingNode::enter(GLState& /* _state */ , unsigned int /* _drawmode */ )
void ClippingNode::enter(GLState& /* _state */ , DrawModes::DrawMode /* _drawmode */ )
{
// one clipping plane
if (slice_width_ == 0.0)
......@@ -157,7 +157,7 @@ void ClippingNode::enter(GLState& /* _state */ , unsigned int /* _drawmode */ )
//----------------------------------------------------------------------------
void ClippingNode::leave(GLState& /* _state */ , unsigned int /* _drawmode */ )
void ClippingNode::leave(GLState& /* _state */ , DrawModes::DrawMode /* _drawmode */ )
{
glDisable(GL_CLIP_PLANE0);
if (slice_width_ > 0.0)
......
......@@ -96,10 +96,10 @@ public:
ACG_CLASSNAME(ClippingNode);
/// set texture
void enter(GLState& _state, unsigned int _drawmode);
void enter(GLState& _state, DrawModes::DrawMode _drawmode);
/// restores original texture (or no-texture)
void leave(GLState& _state, unsigned int _drawmode);
void leave(GLState& _state, DrawModes::DrawMode _drawmode);
/// set position and normal of plane
void set_plane(const Vec3f& _position, const Vec3f& _normal, float _eps=0.0);
......
......@@ -82,7 +82,7 @@ CoordFrameNode(BaseNode* _parent, const std::string& _name)
//-----------------------------------------------------------------------------
unsigned int
DrawModes::DrawMode
CoordFrameNode::availableDrawModes() const
{
return ( DrawModes::WIREFRAME |
......@@ -105,7 +105,7 @@ CoordFrameNode::boundingBox(Vec3d& _bbMin, Vec3d& _bbMax)
void
CoordFrameNode::draw(GLState& /* _state */ , unsigned int /* _drawMode */ )
CoordFrameNode::draw(GLState& /* _state */ , DrawModes::DrawMode /* _drawMode */ )
{
// draw bounding box
......
......@@ -93,11 +93,11 @@ public:
/// implement className()
ACG_CLASSNAME(CoordFrameNode);
/// return available draw modes
unsigned int availableDrawModes() const;
DrawModes::DrawMode availableDrawModes() const;
/// update bounding box
void boundingBox(Vec3d& _bbMin, Vec3d& _bbMax);
/// drawing the primitive
void draw(GLState& _state, unsigned int _drawMode);
void draw(GLState& _state, DrawModes::DrawMode _drawMode);
/// update bounding box (compute in from BB of children)
......
......@@ -77,7 +77,7 @@ boundingBox(Vec3d& /*_bbMin*/, Vec3d& /*_bbMax*/)
//----------------------------------------------------------------------------
unsigned int
DrawModes::DrawMode
CoordsysNode::
availableDrawModes() const
{
......@@ -208,7 +208,7 @@ CoordsysNode::drawCoordsysPick( GLState& _state) {
void
CoordsysNode::
draw(GLState& _state , unsigned int /*_drawMode*/)
draw(GLState& _state , DrawModes::DrawMode /*_drawMode*/)
{
GLboolean colorMask[4];
glGetBooleanv (GL_COLOR_WRITEMASK, colorMask);
......
......@@ -104,13 +104,13 @@ public:
ACG_CLASSNAME(CoordsysNode);
/// return available draw modes
unsigned int availableDrawModes() const;
ACG::SceneGraph::DrawModes::DrawMode availableDrawModes() const;
/// update bounding box
void boundingBox(Vec3d& _bbMin, Vec3d& _bbMax);
/// draw Coordsys
void draw(GLState& _state, unsigned int _drawMode);
void draw(GLState& _state, DrawModes::DrawMode _drawMode);
/// draw Coordsys for object picking
void pick(GLState& _state, PickTarget _target);
......
This diff is collapsed.
This diff is collapsed.
......@@ -78,7 +78,7 @@ EnvMapNode::EnvMapNode( BaseNode* _parent,
//----------------------------------------------------------------------------
unsigned int EnvMapNode::availableDrawModes() const
DrawModes::DrawMode EnvMapNode::availableDrawModes() const
{
return ACG::SceneGraph::DrawModes::SOLID_ENV_MAPPED;
}
......@@ -87,7 +87,7 @@ unsigned int EnvMapNode::availableDrawModes() const
//----------------------------------------------------------------------------
void EnvMapNode::enter(GLState& _state, unsigned int _drawmode)
void EnvMapNode::enter(GLState& _state, DrawModes::DrawMode _drawmode)
{
if (_drawmode==DrawModes::SOLID_ENV_MAPPED)
{
......@@ -105,7 +105,7 @@ void EnvMapNode::enter(GLState& _state, unsigned int _drawmode)
//----------------------------------------------------------------------------
void EnvMapNode::leave(GLState& _state, unsigned int _drawmode)
void EnvMapNode::leave(GLState& _state, DrawModes::DrawMode _drawmode)
{
if (_drawmode==DrawModes::SOLID_ENV_MAPPED)
{
......@@ -119,13 +119,13 @@ void EnvMapNode::leave(GLState& _state, unsigned int _drawmode)
void EnvMapNode::enterPick(GLState& /*_state*/ ,
PickTarget /*_target*/,
unsigned int /*_drawMode*/ ) {
DrawModes::DrawMode /*_drawMode*/ ) {
}
void EnvMapNode::leavePick(GLState& /*_state*/,
PickTarget /*_target*/,
unsigned int /*_drawMode*/ ) {
DrawModes::DrawMode /*_drawMode*/ ) {
}
......
......@@ -87,21 +87,21 @@ public:
ACG_CLASSNAME(EnvMapNode);
/// add env mapping
unsigned int availableDrawModes() const;
DrawModes::DrawMode availableDrawModes() const;
/// set texture
void enter(GLState& _state, unsigned int _drawmode);
void enter(GLState& _state, DrawModes::DrawMode _drawmode);
/// restores original texture (or no-texture)
void leave(GLState& _state, unsigned int _drawmode);
void leave(GLState& _state, DrawModes::DrawMode _drawmode);
/** \brief Do nothing in picking
*/
void enterPick(GLState& _state, PickTarget _target, unsigned int _drawMode );
void enterPick(GLState& _state, PickTarget _target, DrawModes::DrawMode _drawMode );
/** \brief Do nothing in picking
*/
void leavePick(GLState& _state, PickTarget _target, unsigned int _drawMode );
void leavePick(GLState& _state, PickTarget _target, DrawModes::DrawMode _drawMode );
};
......
......@@ -81,7 +81,7 @@ boundingBox(Vec3d& _bbMin, Vec3d& _bbMax)
//----------------------------------------------------------------------------
unsigned int
DrawModes::DrawMode
GlutPrimitiveNode::
availableDrawModes() const
{
......@@ -98,7 +98,7 @@ availableDrawModes() const
void
GlutPrimitiveNode::
draw(GLState& _state, unsigned int _drawMode)
draw(GLState& _state, DrawModes::DrawMode _drawMode)
{
glDepthFunc(depthFunc());
glPushMatrix();
......
......@@ -128,13 +128,13 @@ public:
/// return available draw modes
unsigned int availableDrawModes() const;
DrawModes::DrawMode availableDrawModes() const;
/// update bounding box
void boundingBox(Vec3d& _bbMin, Vec3d& _bbMax);
/// drawing the primitive
void draw(GLState& _state, unsigned int _drawMode);
void draw(GLState& _state, DrawModes::DrawMode _drawMode);
void draw_obj() const;
/// picking
void pick(GLState& _state, PickTarget _target);
......
......@@ -86,7 +86,7 @@ GridNode(BaseNode* _parent, const std::string& _name)
//-----------------------------------------------------------------------------
unsigned int
DrawModes::DrawMode
GridNode::availableDrawModes() const
{
return ( DrawModes::WIREFRAME |
......@@ -118,7 +118,7 @@ GridNode::pick(GLState& _state, PickTarget _target)
void
GridNode::draw(GLState& _state , unsigned int /* _drawMode */ )
GridNode::draw(GLState& _state , DrawModes::DrawMode /* _drawMode */ )
{
glPushAttrib( GL_LIGHTING_BIT ); // STACK_ATTRIBUTES <- LIGHTING_ATTRIBUTE
......
......@@ -92,11 +92,11 @@ public:
/// implement className()
ACG_CLASSNAME(GridNode);
/// return available draw modes
unsigned int availableDrawModes() const;
ACG::SceneGraph::DrawModes::DrawMode availableDrawModes() const;
/// update bounding box
void boundingBox(Vec3d& _bbMin, Vec3d& _bbMax);
/// drawing the primitive
void draw(GLState& _state, unsigned int _drawMode);
void draw(GLState& _state, DrawModes::DrawMode _drawMode);
/// don't pick me
void pick(GLState& _state, PickTarget _target);
public:
......
......@@ -77,7 +77,7 @@ LightSourceNode::LightSourceNode( BaseNode* _parent,
//----------------------------------------------------------------------------
void LightSourceNode::enter(GLState& _state, unsigned int /* _drawmode */ )
void LightSourceNode::enter(GLState& _state, DrawModes::DrawMode /* _drawmode */ )
{
// save old lights
for(unsigned int i=0; i<lightsSave_.size(); i++)
......@@ -116,7 +116,7 @@ void LightSourceNode::enter(GLState& _state, unsigned int /* _drawmode */ )
//----------------------------------------------------------------------------
void LightSourceNode::leave(GLState& /* _state */ , unsigned int /* _drawmode*/ )
void LightSourceNode::leave(GLState& /* _state */ , DrawModes::DrawMode /* _drawmode*/ )
{
// restore old enabled lights
for(unsigned int i=0; i<lights_.size(); i++)
......
......@@ -137,9 +137,9 @@ public:
ACG_CLASSNAME(LightSourceNode);
/// set current Light Sources
void enter(GLState& _state, unsigned int _drawmode);
void enter(GLState& _state, DrawModes::DrawMode _drawmode);
/// restores original Light Sources
void leave(GLState& _state, unsigned int _drawmode);
void leave(GLState& _state, DrawModes::DrawMode _drawmode);
/// enable LightSource _nr
void enable(GLenum _nr)
......
......@@ -88,7 +88,7 @@ boundingBox(Vec3d& _bbMin, Vec3d& _bbMax)
//----------------------------------------------------------------------------
unsigned int
DrawModes::DrawMode
LineNode::
availableDrawModes() const
{
......@@ -101,7 +101,7 @@ availableDrawModes() const
void