arbeit
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

Constraint.h

Go to the documentation of this file.
00001 //------------------------------------------------------------------------
00002 //
00003 //   Joe Kniss
00004 //     8-20-03
00005 //                   ________    ____   ___ 
00006 //                  |        \  /    | /  /
00007 //                  +---+     \/     |/  /
00008 //                  +--+|  |\    /|     < 
00009 //                  |  ||  | \  / |  |\  \ 
00010 //                  |      |  \/  |  | \  \ 
00011 //                   \_____|      |__|  \__\
00012 //                       Copyright  2003 
00013 //                      Joe Michael Kniss
00014 //                   <<< jmk@cs.utah.edu >>>
00015 //               "All Your Base are Belong to Us"
00016 //-------------------------------------------------------------------------
00017 
00018 /// Constraint.h
00019 
00020 #ifndef __WIDGET_CONSTRAINT_DOT_H
00021 #define __WIDGET_CONSTRAINT_DOT_H
00022 
00023 #include <mathGutz.h>
00024 #include <eventGutz.h>
00025 #include "WidgetDefs.h"
00026 
00027 ///////////////////////////////////////////////////////////////////////////
00028 /// a base class for widget constraints, also implements the
00029 ///  "Free Move" constraint, which is really no constraint at all :)
00030 ///////////////////////////////////////////////////////////////////////////
00031 class Constraint : public gutz::Counted {
00032 public:
00033    Constraint(){}
00034    virtual ~Constraint() {}
00035 
00036    /// getMoveBy, returs space delta, takes the current space 
00037    ///   position (not the pick pos, but the point that needs to be constrained), 
00038    ///    and the move event.
00039    virtual gutz::vec3f getMoveBy(gutz::vec3f pos, const gutz::MouseMoveEvent &mme) const
00040    { return mme.getWorldDel(); }
00041 
00042 protected:
00043 };
00044 typedef gutz::SmartPtr<Constraint> ConstraintSP;
00045 
00046 /// maps a gutz button to a constraint.
00047 typedef std::map<unsigned int,ConstraintSP,gutz::eventKeyMapCmp> ConstraintMap;
00048 
00049 
00050 ///////////////////////////////////////////////////////////////////////////
00051 /// constrain to plane, makes sure moves stay on the plane and below the mouse
00052 ///////////////////////////////////////////////////////////////////////////
00053 class PlaneConstraint : public Constraint {
00054 public:
00055    PlaneConstraint(const gutz::planef &pl)
00056       : Constraint(), _plane(pl)
00057    {}
00058    virtual ~PlaneConstraint() {}
00059 
00060    virtual gutz::vec3f getMoveBy(gutz::vec3f pos, const gutz::MouseMoveEvent &mme)
00061    { return mme.getWorldDel(); }
00062 
00063    void         setPlane(const gutz::planef &pl) { _plane = pl; }
00064    gutz::planef getPlane() const                 { return _plane; }
00065 
00066 protected:
00067    gutz::planef _plane;
00068 };
00069 typedef gutz::SmartPtr<PlaneConstraint> PlaneConstraintSP;
00070 
00071 
00072 #endif
00073 
00074 

Send questions, comments, and bug reports to:
jmk