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

NodeWidget.cpp

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.cpp
00019 
00020 #include "NodeWidget.h"
00021 #include <iostream>
00022 
00023 using namespace gutz;
00024 using namespace std;
00025 
00026 ///////////////////////////////////////////////////////////////////////////
00027 ///////////////////////////////////////////////////////////////////////////
00028 /// NodeWidget
00029 ///////////////////////////////////////////////////////////////////////////
00030 ///////////////////////////////////////////////////////////////////////////
00031 
00032 ///////////////////////////////////////////////////////////////////////////
00033 /// Construct
00034 NodeWidget::NodeWidget( vec3f pos, float rad, WidgetItem *parent )
00035 : WidgetItem( parent ), _rad(rad)
00036 {
00037    _manip->setWorldPos(pos);
00038 }
00039 
00040 ///////////////////////////////////////////////////////////////////////////
00041 /// Set Point
00042 void  NodeWidget::setPoint(const gutz::vec3f &wpos)
00043 {
00044    if( _manip->getParent() ) 
00045       setPointLocal( _manip->getParent()->getLocalPosWorld(wpos) );
00046    else
00047       setPointLocal( wpos );
00048 }
00049 
00050 void NodeWidget::setPointLocal(const gutz::vec3f &lpos)
00051 {
00052    /// this is key, don't want infinite updates!!!!
00053    /// if we don't move, we don't update...
00054    if( getPointLocal() == lpos ) return;
00055    
00056    _invalidate();
00057    {
00058       _manip->setLocalPos(lpos);
00059    }
00060    _update();
00061 
00062    pointChanged( getPoint() );
00063 }
00064 
00065 
00066 #if 0
00067 ///////////////////////////////////////////////////////////////////////////
00068 /// Move by
00069 bool NodeWidget::moveDef(const gutz::MouseMoveEvent &mme)
00070 {
00071    return _manip->move(mme);
00072 
00073    switch(getEvent(mme))
00074    {
00075    case MOVE:
00076       /// TODO: some error checking, but really should go away...
00077       if(!_constraintMap[mme.getButton()])
00078       {
00079          cerr << "NodeWidget::moveDef(), constraint not defined, going default" << endl;
00080          cerr << "   - button = " << mme.getButton() << " , event = " 
00081             << getEvent(mme) << endl;
00082          _constraintMap[mme.getButton()] = new Constraint();
00083       }
00084       setPointLocal( _manip->getLocalPos() 
00085          + _constraintMap[mme.getButton()]->getMoveBy(_manip->getLocalPos(),mme) );
00086       break;
00087    }
00088    return true;
00089 }
00090 #endif
00091 
00092 ///////////////////////////////////////////////////////////////////////////
00093 /// areaPoints
00094 WidgetItem::Point2Array NodeWidget::getValidArea() const
00095 {
00096    vec3f pos = getPoint();
00097    Point2Array b(4,Point2(0));
00098    b[0] = Point2(pos.x - _rad, pos.y - _rad);
00099    b[1] = Point2(pos.x + _rad, pos.y - _rad);
00100    b[2] = Point2(pos.x + _rad, pos.y + _rad);
00101    b[3] = Point2(pos.x - _rad, pos.y + _rad);
00102 
00103    return b;
00104 }

Send questions, comments, and bug reports to:
jmk