UVTexIntegra 310.0.0.3

- メインページ
- 関連ページ
- モジュール
- ネームスペース
- クラス
- ファイル

- ファイル一覧

全て クラス ネームスペース 関数 変数 列挙型 プロパティ イベント グループ ページ
MainEditForm.hpp
1 // == LICENSE INFORMATION ==
2 /*
3 * First author tiritomato 2013.
4 * This program is distributed under the GNU General Public License(GPL).
5 * support blog (Japanese only) http://d.hatena.ne.jp/tiri_tomato/
6 */
7 // == LICENSE INFORMATION ==
8
9 #pragma once
10
11 namespace UVTexIntegra {
12 namespace CustomControls {
13
14 using namespace OpenTK::Graphics;
15 using namespace OpenTK::Graphics::OpenGL;
16
17 // pre define
18 struct UVTransformedBuffer;
19 ref class MainEditForm;
20
23
24 public ref class Plugin : MQCLI::CommandPlugin {
25 public:
26 Plugin();
27 virtual BOOL Activate(MQDocument doc, BOOL flag) override;
28 virtual void Exit() override;
29 virtual BOOL IsActivated(MQDocument doc) override;
30 virtual void OnEndDocument(MQDocument doc) override;
31 virtual void OnMaterialModified(MQDocument doc) override;
32 virtual void OnNewDocument(MQDocument doc, const char *filename, MQStationPlugin::NEW_DOCUMENT_PARAM& param) override;
33 virtual void OnUpdateMaterialList(MQDocument doc) override;
34 virtual void OnUpdateObjectList(MQDocument doc) override;
35 virtual void OnSaveDocument(MQDocument doc, const char *filename, MQStationPlugin::SAVE_DOCUMENT_PARAM& param) override;
36 virtual bool OnException(System::Exception^ ex);
37 private:
38 MainEditForm^ m_dlg;
39 };
40
42 public ref class MainEditForm : MainEditForm_Base {
43 private:
45 ref class ConfigAdapter : IConfig {
46 public:
48 virtual property System::Int32 BakeTextureBaseColor
49 {
50 System::Int32 get() { return m_dlg->BakeTextureBaseColor; }
51 void set(System::Int32 value) { m_dlg->BakeTextureBaseColor = value; }
52 }
53
55 virtual property float BakeTextureBorder
56 {
57 float get() { return m_dlg->BakeTextureBorder; }
58 void set(float value) { m_dlg->BakeTextureBorder = value; }
59 }
60
62 virtual property System::Drawing::Size BakeTextureImageSize
63 {
64 System::Drawing::Size get() { return System::Drawing::Size(m_dlg->BakeTextureW, m_dlg->BakeTextureH); }
65 void set(System::Drawing::Size value)
66 {
67 m_dlg->BakeTextureW = value.Width;
68 m_dlg->BakeTextureH = value.Height;
69 }
70 }
71
73 virtual property System::String^ BakeTextureLastFilePath {
74 System::String^ get() { return m_dlg->BakeTextureLastFilePath; }
75 void set(System::String^ value) { m_dlg->BakeTextureLastFilePath = value; }
76 }
77
79 virtual property UVTexIntegra::CanvasMode CanvasMode
80 {
81 UVTexIntegra::CanvasMode get()
82 {
83 if ( m_dlg->rdbDisplayVColorPreview->Checked ) return UVTexIntegra::CanvasMode::VertexColorPreview;
84 return UVTexIntegra::CanvasMode::Normal;
85 }
86 }
87
90 virtual property IDocumentFormat^ Document { IDocumentFormat^ get() { return m_doc; } }
91
93 virtual property System::Drawing::Size FormSize { System::Drawing::Size get() { return m_dlg->Size; } }
94
96 virtual property int GridResolution { int get() { return m_dlg->GridResolution; } }
97
99 virtual property System::Drawing::Size TextureSetFormSize
100 {
101 System::Drawing::Size get() { return m_dlg->TexSetFormSize; }
102 void set(System::Drawing::Size value) { m_dlg->TexSetFormSize = value; }
103 }
104
105 ConfigAdapter( MainEditForm^ dlg );
106
107 private:
108 MainEditForm^ m_dlg;
109 IDocumentFormat^ m_doc;
110 };
111
112 public:
113
115 ref class Document : IDocumentFormat {
116 public:
117 virtual property bool IsCloneTrans {
118 bool get() { return m_payload->IsCloneTrans; }
119 private: void set(bool value) sealed { m_payload->IsCloneTrans = value; }
120 }
121 virtual property bool IsRecursiveTrans {
122 bool get() { return m_payload->IsRecursiveTrans; }
123 private: void set(bool value) sealed { m_payload->IsRecursiveTrans = value; }
124 }
125 virtual property bool IsIntegrateTexture {
126 bool get() { return m_payload->IsIntegrateTexture; }
127 private: void set(bool value) sealed { m_payload->IsIntegrateTexture = value; }
128 }
129 virtual property bool IsClrTextureOnIntegrate {
130 bool get() { return m_payload->IsClrTextureOnIntegrate; }
131 private: void set(bool value) sealed { m_payload->IsClrTextureOnIntegrate = value; }
132 }
133 virtual property bool IsIntegrateAlpha {
134 bool get() { return m_payload->IsIntegrateAlpha; }
135 private: void set(bool value) sealed { m_payload->IsIntegrateAlpha = value; }
136 }
137 virtual property bool IsClrAlphaOnIntegrate {
138 bool get() { return m_payload->IsClrAlphaOnIntegrate; }
139 private: void set(bool value) sealed { m_payload->IsClrAlphaOnIntegrate = value; }
140 }
141 virtual property bool IsIntegrateBump {
142 bool get() { return m_payload->IsIntegrateBump; }
143 private: void set(bool value) sealed { m_payload->IsIntegrateBump = value; }
144 }
145 virtual property bool IsClrBumpOnIntegrate {
146 bool get() { return m_payload->IsClrBumpOnIntegrate; }
147 private: void set(bool value) sealed { m_payload->IsClrBumpOnIntegrate = value; }
148 }
149 virtual property System::Int32 TextureClearColor {
150 System::Int32 get() { return m_payload->TextureClearColor; }
151 private: void set(System::Int32 value) sealed { m_payload->TextureClearColor = value; }
152 }
153 virtual property System::Int32 AlphaClearColor {
154 System::Int32 get() { return m_payload->AlphaClearColor; }
155 private: void set(System::Int32 value) sealed { m_payload->AlphaClearColor = value; }
156 }
157 virtual property System::Int32 BumpClearColor {
158 System::Int32 get() { return m_payload->BumpClearColor; }
159 private: void set(System::Int32 value) sealed { m_payload->BumpClearColor = value; }
160 }
162 bool IsComboboxIndexSelecting;
163 property bool IsEmpty { bool get(){ return m_payload->EditDataItems->Count < 1; } }
164 virtual property ::MQDocument MQDocument {
165 ::MQDocument get() { return m_payload->MQDocument; }
166 void set( ::MQDocument value ) { m_payload->MQDocument = value; }
167 }
168 virtual property System::Collections::ObjectModel::ReadOnlyCollection<EditData^>^ EditDataItems {
169 System::Collections::ObjectModel::ReadOnlyCollection<EditData^>^ get() { return m_payload->ReadonlyEditDataItems; }
170 }
171
173 Document() :
174 m_payload(gcnew DocumentFormat()),
175 m_refreshingLock(DotNetEx::CounterKey::UsingKey()),
176 IsComboboxIndexSelecting(false)
177 {
178 }
179
180 void BakeTexturePaint(MainEditForm^ dlg, System::Drawing::Graphics^ g, System::Drawing::Size size);
181
186 bool IsIncludeNotChangeMaterialSetting();
187
189 virtual EditData^ ItemFromID( const UINT UniqueID ) { return m_payload->ItemFromID(UniqueID); }
191 virtual EditData^ ItemFromName( System::String^ matName ) { return m_payload->ItemFromName(matName); }
193 virtual EditData^ ItemFromIndex( const int index ) { return m_payload->ItemFromIndex(index); }
195 virtual int ItemIndexFromID( const UINT UniqueID ) { return m_payload->ItemIndexFromID(UniqueID); }
198 virtual EditData::SelectedCollection^ ItemsOnSelected() { return ItemsOnSelected(-1); }
203 virtual EditData::SelectedCollection^ ItemsOnSelected(const int index) { return m_payload->ItemsOnSelected(index); }
204
208 void OnCustomBake(MainEditForm^ dlg);
209
211 void OnInputChanged(MainEditForm^ dlg);
213 void OnMQOLoaded(MainEditForm^ dlg, MQXmlElement elem);
215 void OnMQOModified(MainEditForm^ dlg, bool isCreateOnEmptyList);
217 void OnMQOSave(MainEditForm^ dlg, MQXmlElement elem);
218 void Paint(MainEditForm^ dlg, System::Drawing::Graphics^ g, System::Drawing::Size size, bool isDraging, bool isBorderHighLight);
220 DocumentFormat^ PayloadClone() { return m_payload->Clone(); }
221 // OnMQOLoaded 内部データを強制的に一新 ＞ 内部データとMQOの整合 ＞ 内部データを画面に反映
222 // OnMQOModified 内部データとMQOの整合 ＞ 内部データを画面に反映
223 // RefreshDialog 内部データを画面に反映
228 void RefreshDialog(MainEditForm^ dlg, int materialIndex);
229
231 void SelectedMaterialsReset(MainEditForm^ dlg);
232
234 void SelectedMaterialsToMatClear(MainEditForm^ dlg);
235
237 void TryTrans(MainEditForm^ dlg);
238
239 private:
240 DotNetEx::CounterKey^ m_refreshingLock;
241 DocumentFormat^ m_payload;
242 void PaintDefault(MainEditForm^ dlg, System::Drawing::Graphics^ g, bool isDraging, bool isBorderHighLight);
243 int RecursiveTrans(const MQObject obj, const int depth, std::vector<char>* const buf);
244 };
245
246 static property System::Collections::ObjectModel::ReadOnlyCollection<unsigned int>^ GridResolutions {
247 System::Collections::ObjectModel::ReadOnlyCollection<unsigned int>^ get();
248 }
249 static property System::Drawing::Point EmptyPosition { System::Drawing::Point get(){ return System::Drawing::Point(-1,-1); } }
250 static property System::Drawing::RectangleF EmptyRectangleF { System::Drawing::RectangleF get(){ return System::Drawing::RectangleF(float::NaN,float::NaN,float::NaN,float::NaN); } }
251 static bool IsEmptyRectangleF( System::Drawing::RectangleF rc ) { return float::IsNaN(rc.Left) || float::IsNaN(rc.Top) || float::IsNaN(rc.Width) || float::IsNaN(rc.Height); }
252
253 MainEditForm(Plugin^ plugin);
254 ~MainEditForm() { this->!MainEditForm(); }
255 !MainEditForm();
256
257 BOOL Activate(MQDocument doc, BOOL value);
258 BOOL Activate(BOOL value) { return Activate( m_docData->MQDocument, value ); }
259 void Exit();
260 BOOL IsActivated() { MQCLI::Lock lock( m_lock ); if ( m_isFirstActivate ) return FALSE; return Form::Visible; }
261
262 void OnEndDocument() {
263 m_docData->MQDocument = NULL;
264 m_docData->OnMQOLoaded(this,NULL);
265 }
266
267 void OnMaterialModified(MQDocument doc) {
268 m_docData->MQDocument = doc;
269 m_docData->OnMQOModified(this, false);
270 }
271
272 void OnNewDocument( MQDocument doc, const char *filename, MQStationPlugin::NEW_DOCUMENT_PARAM& param );
273
274 void OnSaveDocument( MQDocument doc, const char *filename, MQStationPlugin::SAVE_DOCUMENT_PARAM& param ) {
275 m_docData->MQDocument = doc;
276 if ( param.elem != NULL ) m_docData->OnMQOSave( this, param.elem );
277 }
278
279 protected:
280 virtual System::Void OnFormClosing(System::Windows::Forms::FormClosingEventArgs^ e) override;
281
282 private:
283 static System::Collections::ObjectModel::ReadOnlyCollection<unsigned int>^ m_gridResolutions;
284 Plugin^ m_ownerPlugin;
285 bool m_isGLRepaintRequested;
286 bool m_isFirstActivate;
287 bool m_isMouseRangeSelecting;
288 bool m_isMouseCanceled;
289
290 System::Object^ m_drawLock;
291 System::Object^ m_lock;
292
293 Document^ m_docData;
294 System::Drawing::Point m_mousePosition;
295 System::Drawing::Point m_mouseDragStartPosition;
296
297 System::Int32 BakeTextureBaseColor;
298 float BakeTextureBorder;
299 System::String^ BakeTextureLastFilePath;
300 int BakeTextureW;
301 int BakeTextureH;
302
305 property int GridResolution { int get(); }
308 property System::Drawing::Point mousePosition { System::Drawing::Point get(); }
310 System::Drawing::Size TexSetFormSize; // privatable
313 System::Drawing::RectangleF GetGridCursorRectangle( System::Drawing::Point pt );
316 System::Drawing::RectangleF GetGridCursorRectangle( System::Drawing::Point ptA, System::Drawing::Point ptB );
317
318 System::Int32 m_glShaderProgram;
319
320 UVTransformedBuffer* m_pUVBuffer;
321
322 System::String^ m_customBakeScriptDirectory;
323 int m_customBakeScriptFileFilterIndex;
324 int m_buildResultWinX, m_buildResultWinY;
325
326 System::Void pnlPaint_CallInvalidate(System::Object^, System::EventArgs^) { pnlGL->Invalidate(); }
327 System::Void btnPilotSwitch_Click ( System::Object^, System::EventArgs^ );
328 System::Void btnMatClr_Click ( System::Object^, System::EventArgs^ );
329 System::Void btnToMatClr_Click ( System::Object^, System::EventArgs^ );
330 System::Void btnTrans_Click ( System::Object^, System::EventArgs^ );
331 System::Void btnBakeVColor_Click ( System::Object^, System::EventArgs^ );
332 System::Void btnCustomBake_Click ( System::Object^, System::EventArgs^ );
333 System::Void cmbSelMat_SelectedIndexChanged ( System::Object^, System::EventArgs^ );
334
335 System::Void pnlGL_GLPrePaintOnce(System::Object^, System::ComponentModel::CancelEventArgs^);
336 System::Void pnlGL_GLPaint(System::Object^, System::Windows::Forms::PaintEventArgs^);
337
338 System::Void txt_KeyUp( System::Object^, System::Windows::Forms::KeyEventArgs^ );
339 System::Void txt_FloatValidating( System::Object^, System::ComponentModel::CancelEventArgs^ );
340 System::Void txt_AbsIntValidating( System::Object^, System::ComponentModel::CancelEventArgs^ );
341 System::Void txt_ColorValidating( System::Object^, System::ComponentModel::CancelEventArgs^ );
342 System::Void chkSelMatTrans_CheckedChanged( System::Object^, System::EventArgs^ );
343 System::Void pluginData_InputChanged( System::Object^, System::EventArgs^ );
344
345 System::Void cmbResolution_SelectedIndexChanged( Object^ sender, System::EventArgs^ e );
346 System::Void pnlGL_GLMouseMove(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e);
347 };
348
350 }
351 }