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

NodeWidget.h

Go to the documentation of this file.
00001 //------------------------------------------------------------------------
00002 //
00003 //   Joe Kniss
00004 //     6-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 /// NodeWidget.h
00019 
00020 
00021 #ifndef __NODE_WIDGET_DOT_H
00022 #define __NODE_WIDGET_DOT_H
00023 
00024 #include "WidgetBase.h"
00025 
00026 const gutz::vec4f defNodeColor = gutz::vec4f(.4256f, .4000f, .9412f, 1.0f);
00027 
00028 ///////////////////////////////////////////////////////////////////////////
00029 ///////////////////////////////////////////////////////////////////////////
00030 /// a Node (point) also can keep track of edges it is connected to
00031 ///////////////////////////////////////////////////////////////////////////
00032 ///////////////////////////////////////////////////////////////////////////
00033 class NodeWidget: public WidgetItem
00034 {
00035 public:
00036    virtual ~NodeWidget() {}
00037 
00038    /// assingment operator, just copies position
00039    NodeWidget &operator=(const NodeWidget &nw)
00040    {
00041       WidgetItem::operator =(nw);
00042       setPoint(nw.getPoint());
00043       setRad(nw.getRad());
00044       return *this;
00045    }
00046 
00047    HAS_SLOTS;
00048 
00049    /////////////////////////////////////////////
00050    ///@name Clones
00051    ///@{
00052 
00053    /// WidgetItem::clone definition
00054    WidgetItem *clone() const
00055    {  return cloneNode(); }
00056 
00057    /// Pure virtual cloneNode(), must be defined in 
00058    ///   (all) concrete NodeWidget classes
00059    virtual NodeWidget *cloneNode() const = 0;
00060    
00061    ///@}
00062    /////////////////////////////////////////////
00063 
00064    /// object changed
00065    virtual void setChanged()
00066    {
00067       pointChanged(getPoint());
00068    }
00069 
00070    /////////////////////////////////////////////
00071    ///@name set/get the position of this object. 
00072    ///  also updates calls pointChanged
00073    ///@{
00074 
00075    /// set point, WORLD space
00076    virtual void  setPoint(const gutz::vec3f &wpos);
00077    /// get point, WORLD space
00078    gutz::vec3f   getPoint() const                { return _manip->getWorldPos(); }
00079    /// set point, LOCAL space
00080    virtual void  setPointLocal( const gutz::vec3f &lpos );
00081    /// get point, LOCAL space
00082    gutz::vec3f   getPointLocal() const           { return _manip->getLocalPos(); }
00083    ///@}
00084    /////////////////////////////////////////////
00085 
00086    /////////////////////////////////////////////
00087    ///@name set/get the diameter of the node 
00088    ///@{
00089    virtual void  setRad(float r) 
00090    { if(_rad == r) return; _rad = r; radChanged(_rad); appearanceChanged();}
00091    float         getRad() const  { return _rad;}
00092    ///@}
00093    /////////////////////////////////////////////
00094 
00095    /////////////////////////////////////////////
00096    ///@name Signals
00097    ///@{
00098 
00099    /// signal: pointChanged(const vec3f &pt), sends WORLD space position
00100    gutz::Signal<const gutz::vec3f &> pointChanged;
00101 
00102    /// signal: radChanged(float r)
00103    gutz::Signal<float> radChanged;
00104 
00105    ///@}
00106    /////////////////////////////////////////////
00107 
00108    /// polygonalItem interface stuff
00109    virtual Point2Array getValidArea() const;
00110 
00111    /////////////////////////////////////////////
00112    ///@name Behaviors from WidgetItem
00113    ///   using default mouseDef() from WidgetItem
00114    ///@{
00115    //virtual bool moveDef(const gutz::MouseMoveEvent &mme);
00116    ///@}
00117    /////////////////////////////////////////////
00118 
00119    /// transform the widget
00120    virtual void    applyXform(gutz::mat4f xf)
00121    {  setPoint(xf.tpoint(getPoint())); }
00122 
00123 protected:
00124 
00125    NodeWidget( gutz::vec3f pos, float rad, WidgetItem *parent = 0 );
00126 
00127    NodeWidget(const NodeWidget &nw)
00128       : WidgetItem(nw), _rad(nw._rad)
00129    {
00130    }
00131 
00132    float        _rad;
00133 
00134 };
00135 
00136 typedef gutz::SmartPtr<NodeWidget> NodeWidgetSP;
00137 typedef std::vector<NodeWidgetSP>  NodeWidgetVec;
00138 typedef NodeWidgetVec::iterator    NodeWidgetVecIter;
00139 
00140 
00141 #endif
00142 
00143 

Send questions, comments, and bug reports to:
jmk