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

TFViewWidget.h

Go to the documentation of this file.
00001 //------------------------------------------------------------------------
00002 //
00003 //   Joe Kniss
00004 //     9-01-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 // TFViewWidget.h
00019 
00020 // a base interface for transfer function views, ie 2D projections
00021 
00022 #ifndef __TF_VIEW_WIDGET_DOT_H
00023 #define __TF_VIEW_WIDGET_DOT_H
00024 
00025 #include <widget/FrameWidget.h>
00026 #include "TFSurfaceWidget.h"
00027 #include <signalGutz.h>
00028 
00029 /// TFViewWidget, a class for handling interaction in 2D projections of 
00030 ///   transfer function domain.  
00031 class TFViewWidget : public FrameWidget {
00032 public:
00033    
00034    /// must be constructed with a valid TFSurface proto and a factory!
00035    /// see TFSurfaceWidget and GLTFSurfaceWidget
00036    TFViewWidget(TFSurfaceWidget *const surfProto, 
00037                 const WidgetFactory &wf, 
00038                 WidgetItem          *parent = 0, 
00039                 const gutz::vec3f   &ll = gutz::vec3f(-1,-1,0),
00040                 const gutz::vec3f   &lr = gutz::vec3f(1,-1,0),
00041                 const gutz::vec3f   &ul = gutz::vec3f(-1,1,0),
00042                 const gutz::vec3f   &ur = gutz::vec3f(1,1,0));
00043 
00044    TFViewWidget &operator=(const TFViewWidget &tfv)
00045    {
00046       FrameWidget::operator =(tfv);
00047       return *this;
00048    }
00049 
00050    ///@name Axes
00051    ///   May not always be meaningfull, but it is very convenient for this 
00052    ///    widget to store this information, even though that exposes (some of)
00053    ///    the "symantics" of this widget, it is called TFViewWidget after all :). \n
00054    ///    Mostly done to save time and effort spent in keeping around a map from 
00055    ///    TFViewWidgets -> axies and visa-versa. \n
00056    ///    By Default axes == (0,1)
00057    ///@{
00058    gutz::vec2i getAxes() const                  { return _axes; }
00059    gutz::vec2i setAxes(const gutz::vec2i &axes) { _axes = axes; }
00060    ///@}
00061 
00062    HAS_SLOTS;
00063 
00064    ///@name Signals
00065    ///@{
00066 
00067    /// insertElementEvent(const gutz::vec2i axes, const vec2f& pos) signal. 
00068    ///   The surface of the transfer function was clicked,
00069    ///   and that event maps to the insert event.  The first parameter
00070    ///   is the axes idicies of the view that emmited the event, and
00071    ///   the last one is the (0,1) range position of that click within
00072    ///   the TFViewWidgets frame.
00073    gutz::Signal<const gutz::vec2i&, const gutz::vec2f&>  insertElementEvent;
00074 
00075    ///@}
00076 
00077    ///@name TFSurface set/get/del
00078    ///  The tf surface should be the same object as the SurfaceWidget
00079    ///   contained in the FrameWidget level of the hierarchy
00080    ///@{
00081    void               setTFSurface(TFSurfaceWidget *sw);
00082    TFSurfaceWidgetSP  getTFSurface() const { return _tfsurf; }
00083    void               delTFSurface();
00084    ///@}
00085 
00086    ///@name Behaviors
00087    ///@{
00088 
00089    /// draw just forwards event to children, this widget
00090    /// is a composite so we don't draw anything ourselves.
00091    virtual void drawDef(const gutz::RenderEvent &r)
00092    {
00093       FrameWidget::drawDef(r);
00094    }
00095 
00096    virtual bool mouseChild(WidgetItem *child, const gutz::MouseEvent &me);
00097 
00098    ///   override of FrameWidget::moveChild
00099    virtual bool moveChild(WidgetItem *child, const gutz::MouseMoveEvent &mme);
00100    
00101    ///@}
00102 
00103 
00104 protected:
00105    TFViewWidget(); ///< not used
00106    /// copy
00107    TFViewWidget(const TFViewWidget &tfv)
00108       : FrameWidget(tfv), _tfsurf(0)
00109    {
00110       if(tfv._tfsurf)
00111          setTFSurface(tfv._tfsurf->cloneTFSurface());
00112    }
00113 
00114    /// the tf surface widget
00115    TFSurfaceWidgetSP _tfsurf;
00116 
00117    /// the axies we represent
00118    gutz::vec2i       _axes;
00119 };
00120 typedef gutz::SmartPtr<TFViewWidget> TFViewWidgetSP;
00121 
00122 #endif

Send questions, comments, and bug reports to:
jmk