nux-1.16.0
Matrix3Editor.h
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 MATRIX3EDITOR_H
00024 #define MATRIX3EDITOR_H
00025 
00026 #include "EditTextBox.h"
00027 #include "StaticTextBox.h"
00028 #include "Layout.h"
00029 #include "HLayout.h"
00030 #include "VLayout.h"
00031 #include "ToggleButton.h"
00032 #include "TimerProc.h"
00033 
00034 namespace nux
00035 {
00036 
00037   class Matrix3Editor;
00038   class Matrix3Preview;
00039 
00041   class Matrix3DialogProxy
00042   {
00043   public:
00044     Matrix3DialogProxy (bool ModalWindow);
00045     ~Matrix3DialogProxy();
00046 
00047     void RecvDialogOk (Matrix3Editor *matrixeditor);
00048     void RecvDialogCancel (Matrix3Editor *matrixeditor);
00049     void RecvDialogChange (Matrix3Editor *matrixeditor);
00050 
00051     void Start();
00052     bool IsActive();
00053     void StopThreadMonitoring();
00054 
00055     Matrix3 GetMatrix()
00056     {
00057       return m_Matrix;
00058     }
00059     void SetMatrix (Matrix3 matrix)
00060     {
00061       m_Matrix = matrix;
00062     }
00063 
00064   private:
00065     bool m_bDialogChange;
00066     bool m_bDialogRunning;
00067 
00068     Matrix3 m_PreviousMatrix;
00069     Matrix3 m_Matrix;
00070 
00071     bool m_ModalWindow;
00072     unsigned int m_DialogThreadID;
00073     NThread *m_Thread;
00074 
00075     friend class Matrix3Preview;
00076   };
00077 
00078 
00079 
00081 
00086   class Matrix3Editor : public View
00087   {
00088   public:
00089     Matrix3Editor (Matrix3 matrix = Matrix3::IDENTITY(), NUX_FILE_LINE_PROTO);
00090     ~Matrix3Editor();
00091     virtual void Draw (GraphicsEngine &GfxContext, bool force_draw);
00092     virtual void DrawContent (GraphicsEngine &GfxContext, bool force_draw);
00093     virtual void PostDraw (GraphicsEngine &GfxContext, bool force_draw);
00094 
00095     void SetParameterName (const char *parameter_name);
00096 
00097     void EmitButtonPress() {};
00098 
00100     //  EMITTERS  //
00102     void EmitIncrementComponent (int index);
00103     void EmitDecrementComponent (int index);
00104     void EmitComponentValue (float f, int index);
00105 
00107     //  RECEIVERS  //
00109 
00111 
00117     void SetMatrix (Matrix3 matrix);
00118 
00120 
00126     Matrix3 GetMatrix() const;
00127 
00128 
00129 
00131     //  SIGNALS    //
00133     //sigc::signal<void> sigClick;
00134 //    sigc::signal<void, int> sigIncrementComponent;
00135 //    sigc::signal<void, int> sigDecrementComponent;
00136     sigc::signal<void, int, char *> sigValidateKeyboarEntry;
00137 
00138     sigc::signal<void, Matrix3Editor * > sigMatrixChanged;
00139 
00140   private:
00141 
00142 
00143     void RecvIdentityMatrixCmd();
00144     void RecvZeroMatrixCmd();
00145     void RecvInverseMatrixCmd();
00146     void RecvNegateMatrixCmd();
00147 
00148     void WriteMatrix();
00149 
00150     void RecvComponentInput (EditTextBox *textbox, const NString &text, int componentIndex);
00151 
00152   private:
00153     VLayout    *m_vlayout;
00154     VLayout    *mtx_layout;
00155     HLayout    *mtx_row_layout[3];
00156 
00157     EditTextBox *m_MtxInput[3][3];
00158 
00159     ToggleButton     *m_IdentityMtxBtn;
00160     ToggleButton     *m_ZeroMtxBtn;
00161     ToggleButton     *m_InverseMtxBtn;
00162     ToggleButton     *m_NegateMtxBtn;
00163     HLayout    *m_MtxFunctionLayout;
00164 
00165     Matrix3x3<float> m_Matrix;
00166   };
00167 
00168 }
00169 
00170 #endif // MATRIX3EDITOR_H
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends