nux-0.9.46

Nux/Matrix4Editor.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 MATRIX4EDITOR_H
00024 #define MATRIX4EDITOR_H
00025 
00026 #include "EditTextBox.h"
00027 #include "StaticTextBox.h"
00028 #include "Layout.h"
00029 #include "HLayout.h"
00030 #include "VLayout.h"
00031 #include "PushButton.h"
00032 #include "TimerProc.h"
00033 
00034 namespace nux
00035 {
00036 
00037   class Matrix4Editor;
00038   class Matrix4Preview;
00039 
00041   class Matrix4DialogProxy
00042   {
00043   public:
00044     Matrix4DialogProxy (bool ModalWindow);
00045     ~Matrix4DialogProxy();
00046 
00047     void RecvDialogOk (Matrix4Editor *matrixeditor);
00048     void RecvDialogCancel (Matrix4Editor *matrixeditor);
00049     void RecvDialogChange (Matrix4Editor *matrixeditor);
00050 
00051     void Start();
00052     bool IsActive();
00053     void StopThreadMonitoring();
00054 
00055     Matrix4 GetMatrix()
00056     {
00057       return m_Matrix;
00058     }
00059     void SetMatrix (Matrix4 matrix)
00060     {
00061       m_Matrix = matrix;
00062     }
00063 
00064   private:
00065     bool m_bDialogChange;
00066     bool m_bDialogRunning;
00067 
00068     Matrix4 m_PreviousMatrix;
00069     Matrix4 m_Matrix;
00070 
00071     bool m_ModalWindow;
00072     unsigned int m_DialogThreadID;
00073     NThread *m_Thread;
00074 
00075     friend class Matrix4Preview;
00076   };
00077 
00078 
00080 
00085   class Matrix4Editor : public View
00086   {
00087   public:
00088     Matrix4Editor (Matrix4 matrix = Matrix4::IDENTITY(), NUX_FILE_LINE_PROTO);
00089     ~Matrix4Editor();
00090     virtual long ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
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 
00098     void EmitButtonPress() {};
00099 
00101     //  EMITTERS  //
00103     void EmitIncrementComponent (int index);
00104     void EmitDecrementComponent (int index);
00105     void EmitComponentValue (float f, int index);
00106 
00108     //  RECEIVERS  //
00110 
00112 
00118     void SetMatrix (Matrix4 matrix);
00119 
00121 
00127     Matrix4 GetMatrix() const;
00128 
00129 
00130 
00132     //  SIGNALS    //
00134     //sigc::signal<void> sigClick;
00135 //    sigc::signal<void, int> sigIncrementComponent;
00136 //    sigc::signal<void, int> sigDecrementComponent;
00137     sigc::signal<void, int, char *> sigValidateKeyboarEntry;
00138 
00139     sigc::signal<void, Matrix4Editor * > sigMatrixChanged;
00140 
00141   private:
00142     void RecvIdentityMatrixCmd();
00143     void RecvZeroMatrixCmd();
00144     void RecvInverseMatrixCmd();
00145     void RecvNegateMatrixCmd();
00146 
00147     void WriteMatrix();
00148 
00149     void RecvComponentInput (EditTextBox *textbox, const NString &text, int componentIndex);
00150 
00151   private:
00152 
00153     VLayout *m_vlayout;
00154     VLayout *mtx_layout;
00155     HLayout *mtx_row_layout[4];
00156 
00157 
00158     EditTextBox *m_MtxInput[4][4];
00159 
00160     PushButton *m_IdentityMtxBtn;
00161     PushButton *m_ZeroMtxBtn;
00162     PushButton *m_InverseMtxBtn;
00163     PushButton *m_NegateMtxBtn;
00164     HLayout *m_MtxFunctionLayout;
00165 
00166 
00167 //     VLayout vlayout;
00168 //     VLayout mtx_layout;
00169 //     HLayout mtx_row_layout[4];
00170 //
00171 //     //StaticTextBox m_ParameterName;
00172 //
00173 //     EditTextBox m_MtxInput[4][4];
00174 //
00175 //     PushButton m_IdentityMtxBtn;
00176 //     PushButton m_ZeroMtxBtn;
00177 //     PushButton m_InverseMtxBtn;
00178 //     PushButton m_NegateMtxBtn;
00179 //     HLayout m_MtxFunctionLayout;
00180 
00181     Matrix4 m_Matrix;
00182   };
00183 
00184 }
00185 
00186 #endif // MATRIX4EDITOR_H