icurvctl.h

Go to the documentation of this file.
00001 /**********************************************************************
00002  *<
00003     FILE: iurvctl.h
00004 
00005     DESCRIPTION:    CurveControl Interface
00006 
00007     CREATED BY:     Nikolai Sander, Kinetix
00008 
00009     HISTORY:        Created 10/15/98
00010 
00011  *> Copyright (c) 1997, All Rights Reserved.
00012  **********************************************************************/
00013 #pragma once
00014 #include <Wtypes.h>   // Required before commctrl.h
00015 #include <CommCtrl.h> // for HIMAGELIST
00016 #include "maxheap.h"
00017 #include "ref.h"
00018 
00019 #define CURVE_CONTROL_CLASS_ID Class_ID(0x14585773, 0x483a7dcf)
00020 
00021 #define I_RESMAKER_INTERFACE 0x2474334a
00022 
00023 #define WM_CC_SEL_CURVEPT         WM_USER+0x2b70 // lParam = ICurve * , LOWORD(wParam) = number of points selected
00024 #define WM_CC_CHANGE_CURVEPT      WM_USER+0x2b71 // lParam = ICurve * , LOWORD(wParam) = point index
00025 #define WM_CC_CHANGE_CURVETANGENT WM_USER+0x2b72 // lParam = ICurve * , LOWORD(wParam) = point index, HIWORD(wParam) & IN_CURVETANGENT_CHANGED->InTangent, HIWORD(wParam)&OUT_CURVETANGENT_CHANGED->OutTangent
00026 #define WM_CC_DEL_CURVEPT         WM_USER+0x2b73 // lParam = ICurve * , LOWORD(wParam) = point index
00027 #define WM_CC_INSERT_CURVEPT      WM_USER+0x2b74 // lParam = ICurve * , LOWORD(wParam) = point index  (added by AF (6/26/2000) )
00028 #define WM_CC_LBUTTONDOWN         WM_USER+0x2b75 // lParam = ICurve * , LOWORD(wParam) = point index  (added by AF (10/31/2000) )
00029 #define WM_CC_RBUTTONDOWN         WM_USER+0x2b76 // lParam = ICurve * , LOWORD(wParam) = point index  (added by AF (10/31/2000) )
00030 #define WM_CC_LBUTTONUP           WM_USER+0x2b77 // lParam = ICurve * , LOWORD(wParam) = point index  (added by AF (10/31/2000) )
00031 
00032 #define IN_CURVETANGENT_CHANGED  (1<<0)
00033 #define OUT_CURVETANGENT_CHANGED (1<<1)
00034 
00035 #define IN_CURVETANGENT_CHANGED  (1<<0)
00036 #define OUT_CURVETANGENT_CHANGED (1<<1)
00037 
00045 #define CC_DRAWBG               (1<<0) //!< Draw the white background in the graph window.
00046 #define CC_DRAWGRID             (1<<1) //!< Draw the grid lines and coordinates in the graph window.
00047 #define CC_DRAWUTOOLBAR         (1<<2) //!< Draw the upper toolbar above the control.
00048 #define CC_SHOWRESET            (1<<3) //!< Display the Reset button in the upper toolbar.
00049 #define CC_DRAWLTOOLBAR         (1<<4) //!< Draw the lower toolbar beneath the control.
00050 #define CC_DRAWSCROLLBARS       (1<<5) //!< Draw the horizontal and vertical scroll bars for the control.
00051 
00053 #define CC_AUTOSCROLL           (1<<6) //!< Do auto scrolling.
00054 #define CC_DRAWRULER            (1<<7) //!< Draw a small moveable ruler window that measures horizontal coordinates.
00055 
00057 #define CC_ASPOPUP              (1<<8) //!< Create the control as a pop-up with a title string.
00058 #define CC_CONSTRAIN_Y          (1<<9) //!< No points (or handles) can be moved out of the value that is set by SetYRange().
00059 
00060 #define CC_HIDE_DISABLED_CURVES (1<<10) //!< Disabled curves won't be displayed at all.
00061 
00062 // Rightclick menu
00063 #define CC_RCMENU_MOVE_XY       (1<<11) //!< Right-click menu item.
00064 #define CC_RCMENU_MOVE_X        (1<<12) //!< Right-click menu item. 
00065 #define CC_RCMENU_MOVE_Y        (1<<13) //!< Right-click menu item.
00066 #define CC_RCMENU_SCALE         (1<<14) //!< Right-click menu item. 
00067 #define CC_RCMENU_INSERT_CORNER (1<<15) //!< Right-click menu item. 
00068 #define CC_RCMENU_INSERT_BEZIER (1<<16) //!< Right-click menu item. 
00069 #define CC_RCMENU_DELETE        (1<<17) //!< Right-click menu item. 
00070 //watje
00074 #define CC_SHOW_CURRENTXVAL     (1<<18) //!< Allows a vertical bar to be drawn over the graph to show the current X value.
00075 
00077 #define CC_SINGLESELECT         (1<<19) //!< Allows the user to single select a point
00078 
00079 #define CC_NOFILTERBUTTONS      (1<<20) //!< Turns off the curve visible/editable toggle in the top of the menu bar.
00080 #define CC_ALL_RCMENU (CC_RCMENU_MOVE_XY|CC_RCMENU_MOVE_X|CC_RCMENU_MOVE_Y|CC_RCMENU_SCALE|CC_RCMENU_INSERT_CORNER|CC_RCMENU_INSERT_BEZIER|CC_RCMENU_DELETE) //!< Entire right click menu.
00081 #define CC_ALL (CC_DRAWBG|CC_DRAWGRID|CC_DRAWUTOOLBAR|CC_SHOWRESET|CC_DRAWLTOOLBAR|CC_DRAWSCROLLBARS|CC_AUTOSCROLL|CC_DRAWRULER|CC_ASPOPUP|CC_CONSTRAIN_Y|CC_HIDE_DISABLED_CURVES| CC_ALL_RCMENU )  //!< 
00082 #define CC_NONE 0 //!< 
00083 
00084 
00085 #define CID_CC_MOVE_XY              0
00086 #define CID_CC_MOVE_X               1
00087 #define CID_CC_MOVE_Y               2
00088 #define CID_CC_SCALE                3
00089 #define CID_CC_INSERT_CORNER        4
00090 #define CID_CC_INSERT_BEZIER        5
00091 
00092 //Curve out of range types
00093 #define CURVE_EXTRAPOLATE_LINEAR    0
00094 #define CURVE_EXTRAPOLATE_CONSTANT  1
00095 
00096 // IPoint flags
00097 #define CURVEP_BEZIER       (1<<0)
00098 #define CURVEP_CORNER       (1<<1)
00099 #define CURVEP_LOCKED_Y     (1<<2)
00100 #define CURVEP_LOCKED_X     (1<<3)
00101 #define CURVEP_SELECTED     (1<<4)
00102 #define CURVEP_ENDPOINT     (1<<8)  // It's a constrained endpoint on the curve
00103 #define CURVEP_NO_X_CONSTRAINT (1<<9)  //Added by AF (6/26/2000)
00104 
00105 // Flags passed to SelectPts
00106 #define SELPTS_SELECT           (1<<0)  
00107 #define SELPTS_DESELECT         (1<<1)
00108 #define SELPTS_CLEARPTS         (1<<2)       
00109 
00110 #define IS_CORNER(flags)        ( ( (flags) & CURVEP_CORNER) && !((flags) & CURVEP_BEZIER) )
00111 #define IS_BEZIERSMOOTH(flags)  ( ( (flags) & CURVEP_BEZIER) && !((flags) & CURVEP_CORNER) )
00112 #define IS_BEZIERCORNER(flags)  ( (flags) & (CURVEP_BEZIER | CURVEP_CORNER) )
00113 
00114 
00115 
00116 class ICurve;
00117 
00125 class ICurveCtl : public ReferenceTarget {
00126 public:
00127     
00130     virtual BOOL  IsActive()=0;
00135     virtual void  SetActive(BOOL sw)=0;
00137     virtual HWND  GetHWND()=0;
00146     virtual void  SetNumCurves(int iNum, BOOL doUndo=FALSE)=0;
00148     virtual void DeleteAllCurves() = 0;
00150     virtual int   GetNumCurves()=0;
00166     virtual void  SetXRange(float min, float max, BOOL rescaleKeys = TRUE)=0;   // Determines the first and last key for all curves
00174     virtual void  SetYRange(float min, float max)=0;                // Determines the upper and lower limits, if the Flag CC_CONSTRAIN_Y is set
00176     virtual Point2 GetXRange()=0;                                   //Returns the X range as a Point2 (added by AF (6/26/2000) )
00178     virtual Point2 GetYRange()=0;                                   //Returns the Y range as a Point2 (added by AF (6/26/2000) )                            
00179     
00191     virtual void  RegisterResourceMaker(ReferenceMaker *rmak)=0;    // This registers a rmaker, which has to implement GetInterface 
00192                                                                     // for I_RESMAKER_INTERFACE by returning an object derived from 
00193                                                                     // ResourceMakerCallback
00194     
00202     virtual BOOL  GetZoomValues(float *h, float *v)=0;              // Returns the current zoom values
00213     virtual void  SetZoomValues(float h, float v)=0;                // Sets the zoom values
00221     virtual BOOL  GetScrollValues(int *h, int *v)=0;                // Returns the current Scroll Values
00232     virtual void  SetScrollValues(int h, int v)=0;                  // Sets the scroll values
00234     virtual void  ZoomExtents()=0;
00241     virtual void  SetTitle(MCHAR *str)=0;                           // Sets the title of the dialog box
00248     virtual ICurve *GetControlCurve(int numCurve)=0;                // Returns and interface to the numCurve'th curve
00254     virtual void  SetDisplayMode(BitArray &mode)=0;                 // Determines which curves are toggled on
00257     virtual BitArray GetDisplayMode()=0;                            // Returns which curves are toggled on
00262     virtual void  SetCCFlags(DWORD flags)=0;
00264     virtual DWORD GetCCFlags()=0;
00270     virtual void  SetCustomParentWnd(HWND hParent)=0;               // Parent Window, if CurveControl is no popup window
00302     virtual void  SetMessageSink(HWND hWnd)=0;                      // WM_CC_CHANGE_CURVEPT, WM_CC_CHANGE_CURVETANGENT and WM_CC_DEL_CURVEPT will be sent to this window
00314     virtual void  SetCommandMode(int ID)=0;
00324     virtual int   GetCommandMode()=0;
00326     virtual void  Redraw()=0;
00332     virtual Interval    GetValidity(TimeValue t)=0;
00341     virtual void Update(TimeValue t, Interval& valid)=0;
00342 //watje
00343 //this draws a vertical bar at the current value
00349     virtual void SetCurrentXValue(float val)=0;
00350 //this turns on/off the display code.  It is useful when you are doing lots of changes and don't
00351 //want the window to continually redraw
00358     virtual void EnableDraw(BOOL enable)=0;
00359 
00360     virtual void DeleteCurve(int index)=0;                          //Added by AF (08/17/00) (used by reactor)
00361 
00362 };
00363 
00395 class CurvePoint: public MaxHeapOperators
00396 {
00397 public:
00398     Point2 p;
00399     Point2 in;
00400     Point2 out;
00401     int flags;
00402     CurvePoint()
00403         : flags(0)
00404     {
00405         p.x = 0.0f;
00406         p.y = 0.0f;
00407         in.x = 0.0f;
00408         in.y = 0.0f;
00409         out.x = 0.0f;
00410         out.y = 0.0f;
00411     }
00412     CurvePoint& operator=(const CurvePoint& rhs)
00413     {
00414         p       = rhs.p;
00415         in      = rhs.in;
00416         out     = rhs.out;
00417         flags   = rhs.flags;
00418         return *this;
00419     }
00420 };
00421 
00422 
00431 #pragma warning(push)
00432 #pragma warning(disable:4239)
00433 
00434 class ICurve : public ReferenceTarget 
00435 {
00436 public:
00453     virtual void  SetPenProperty(COLORREF color, int width = 0, int style = PS_SOLID)=0; // Sets the pen properties of a curve 
00469     virtual void  GetPenProperty(COLORREF &color, int &width, int &style)=0;                 // Gets the color of a curve
00485     virtual void  SetDisabledPenProperty(COLORREF color, int width = 0, int style = PS_SOLID)=0; // Sets the pen properties of a curve if it is disabled
00501     virtual void  GetDisabledPenProperty(COLORREF &color, int &width, int &style)=0;                 // Gets the color of a curve if it is disabled
00521     virtual float GetValue(TimeValue t, float fX, Interval &ivalid = FOREVER, BOOL UseLookupTable = FALSE)=0;            // Returns the Y-value for a given X-Value
00526     virtual void  SetCanBeAnimated(BOOL Animated)=0;
00529     virtual BOOL  GetCanBeAnimated()=0;
00530 
00536     virtual int   IsAnimated(int index)=0;
00537     
00539     virtual int   GetNumPts()=0;
00544     virtual void  SetNumPts(int count)=0;
00548     virtual BitArray GetSelectedPts()=0;
00564     virtual void  SetSelectedPts(BitArray &sel, int flags)=0;
00565 
00590     virtual void  SetPoint(TimeValue t, int index, CurvePoint *point, BOOL CheckConstraints = TRUE, BOOL notify = TRUE)=0;
00600     virtual CurvePoint  GetPoint(TimeValue t, int index, Interval &valid = FOREVER)=0;
00601 
00602     //Added by AF (10/26/00)
00603     //Currently only supports CURVE_EXTRAPOLATE_LINEAR and CURVE_EXTRAPOLATE_CONSTANT
00610     virtual void  SetOutOfRangeType(int type)=0;
00614     virtual int   GetOutOfRangeType()=0;
00615     
00623     virtual int   Insert(int where, CurvePoint & p)=0;
00624 //watje
00625 //this is identical to the Insert above but allows you to turn off/on the hold that occurs.
00626 //this is useful when you are doing interactive inserts and moves from code, the original Insert hold
00627 //would often get in the way
00639     virtual int   Insert(int where, CurvePoint& p, BOOL do_not_hold)=0;
00640 
00641 
00646     virtual void  Delete(int index)=0;
00647 
00658     virtual void  SetLookupTableSize(int size)=0;
00661     virtual int   GetLookupTableSize()=0;
00662 };
00663 
00664 #pragma warning(pop)
00665 
00674 class ResourceMakerCallback: public MaxHeapOperators
00675 {
00676 public:
00694     #pragma warning(push)
00695     #pragma warning(disable:4100)
00696     virtual BOOL SetCustomImageList(HIMAGELIST& hCTools, ICurveCtl* pCCtl){return FALSE;} 
00697     
00698     // This callback allows the developer to assign custom ToolTips to the display buttons. He simply has to assing a 
00699     // MSTR to the ToolTip parameter in regards to the button number. The pCCtl pointer can be used to determine 
00700     // which ICurveCtl calls the callback, in case the plugin uses many CurveControls and want to set different 
00701     // Tooltips for different CurveControls
00702 
00719     virtual BOOL GetToolTip(int iButton, MSTR &ToolTip,ICurveCtl *pCCtl){return FALSE;}
00720 
00731     virtual void ResetCallback(int curvenum, ICurveCtl *pCCtl){}
00743     virtual void NewCurveCreatedCallback(int curvenum, ICurveCtl *pCCtl){}
00744     
00745     virtual void* GetInterface(ULONG id) {return NULL;}
00746     #pragma warning(pop)
00747 };
00748