nux-0.9.46

Nux/SplineCurvePreview.h

Go to the documentation of this file.
00001 /*
00002  * Copyright 2010 Inalogic® Inc.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License, as
00006  * published by the  Free Software Foundation; either version 2.1 or 3.0
00007  * of the License.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranties of
00011  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00012  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00013  * License for more details.
00014  *
00015  * You should have received a copy of both the GNU Lesser General Public
00016  * License along with this program. If not, see <http://www.gnu.org/licenses/>
00017  *
00018  * Authored by: Jay Taoko <jaytaoko@inalogic.com>
00019  *
00020  */
00021 
00022 
00023 #ifndef SPLINECURVEPICKER_H
00024 #define SPLINECURVEPICKER_H
00025 
00026 #include "TimerProc.h"
00027 
00028 namespace nux
00029 {
00030 
00031   class SplineCurveDialog;
00032   class SplineCurveEditor;
00033   class SplineCurvePreview;
00034   class TimerFunctor;
00035 //struct TimerHandle;
00036 
00037   class SplineCurveDialogProxy
00038   {
00039   public:
00040     SplineCurveDialogProxy (bool ModalWindow);
00041     ~SplineCurveDialogProxy();
00042 
00043     void RecvDialogOk (SplineCurveEditor *splinecurve);
00044     void RecvDialogCancel (SplineCurveEditor *splinecurve);
00045     void RecvDialogChange (SplineCurveEditor *splinecurve);
00046 
00047     void Start();
00048     bool IsActive();
00049     void StopThreadMonitoring();
00050 
00051     const SplineKnot &GetControlPoints() const;
00052     void SetControlPoints (const SplineKnot &);
00053 
00054   private:
00055     SplineKnot m_PreviousControlPoints;
00056     SplineKnot m_ControlPoints;
00057 
00058     SplineCurveEditor *m_Curve;
00059     bool m_bDialogChange;
00060     bool m_bDialogRunning;
00061     unsigned int m_DialogThreadID;
00062     bool m_ModalWindow;
00063     NThread *m_Thread;
00064 
00065     friend class SplineCurvePreview;
00066   };
00067 
00068   class SplineCurvePreview : public View
00069   {
00070   public:
00071     SplineCurvePreview (NUX_FILE_LINE_PROTO);
00072     ~SplineCurvePreview();
00073     virtual long ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
00074     virtual void Draw (GraphicsEngine &GfxContext, bool force_draw);
00075     virtual void DrawContent (GraphicsEngine &GfxContext, bool force_draw);
00076     virtual void PostDraw (GraphicsEngine &GfxContext, bool force_draw);
00077 
00078     void SetXAxisBounds (float minX, float maxX);
00079     void SetYAxisBounds (float minY, float maxY);
00080     void UpdateGraph();
00081 
00082     int GetNumKnot() const;
00083     SplineKnot::Knot GetKnot (int i) const;
00084 
00085     sigc::signal<void, SplineCurveEditor * > sigSplineChanged;
00086     void RecvDialogChange (SplineCurveEditor *splinecurve);
00087 
00088     const SplineKnot &GetControlPoints() const;
00089     void Reset();
00090 
00091   protected:
00092     // used by SplineCurvePropertyItem
00093     void AddKnot (double x, double y, bool bSelected);
00094 
00095   private:
00096     void SetControlPoints (const SplineKnot &);
00097 
00098     double Eval (double t);
00099     void RecvTimer (void *v);
00100     void RecvClick (int x, int y, unsigned long button_flags, unsigned long key_flags);
00101 
00102     float m_minX, m_minY, m_maxX, m_maxY;
00103 
00104     TimerFunctor *m_ChangeDetectionTimer;
00105     TimerHandle m_ChangeTimerHandler;
00106 
00107     TextureLayer *m_BackgroundLayer;
00108     ObjectPtr<IOpenGLBaseTexture> Texture;
00109     GLSh_DrawFunction *m_DrawFunctionShader;
00110     WindowThread *m_WindowDialog;
00111 
00112     SplineCurveDialogProxy *m_DialogThreadProxy;
00113 
00114     SplineKnot m_control_knot;
00115     CubicSpline m_CubicSpline;
00116   };
00117 
00118 
00119 }
00120 
00121 #endif // SPLINECURVEPICKER_H