From 5b9162d2c183376322d36064274ec2dc19742d6e Mon Sep 17 00:00:00 2001 From: Xottab-DUTY Date: Fri, 4 Dec 2015 07:02:52 +0500 Subject: [PATCH] PPEditor: fixed includes and formatted code + add stdafx missing in project file --- src/editors/PPEditor/NoiseFGen.cpp | 31 +- src/editors/PPEditor/NoiseFGen.h | 15 +- src/editors/PPEditor/NoiseGen.cpp | 51 ++- src/editors/PPEditor/NoiseGen.h | 15 +- src/editors/PPEditor/PPEditor.vcxproj | 1 + src/editors/PPEditor/PPEditor.vcxproj.filters | 1 + src/editors/PPEditor/Postprocess.bpr | 18 +- src/editors/PPEditor/Postprocess.cpp | 54 +-- src/editors/PPEditor/Unit6.cpp | 123 ++--- src/editors/PPEditor/Unit6.h | 36 +- src/editors/PPEditor/Unit7.cpp | 12 +- src/editors/PPEditor/Unit7.h | 23 +- src/editors/PPEditor/Unit8.cpp | 119 ++--- src/editors/PPEditor/Unit8.h | 29 +- src/editors/PPEditor/Unit9.cpp | 6 +- src/editors/PPEditor/Unit9.h | 15 +- src/editors/PPEditor/base.h | 35 +- src/editors/PPEditor/color.cpp | 350 +++++++------- src/editors/PPEditor/color.h | 79 ++-- src/editors/PPEditor/effect.cpp | 64 +-- src/editors/PPEditor/effect.h | 57 ++- src/editors/PPEditor/float_constructor.cpp | 142 +++--- src/editors/PPEditor/float_constructor.h | 41 +- src/editors/PPEditor/float_param.cpp | 6 +- src/editors/PPEditor/float_param.h | 23 +- src/editors/PPEditor/main.cpp | 428 +++++++++--------- src/editors/PPEditor/main.h | 90 ++-- src/editors/PPEditor/newdialog.cpp | 17 +- src/editors/PPEditor/newdialog.h | 15 +- src/editors/PPEditor/single_param.cpp | 335 +++++++------- src/editors/PPEditor/single_param.h | 84 ++-- src/editors/PPEditor/spline.cpp | 142 +++--- src/editors/PPEditor/spline.h | 48 +- src/editors/PPEditor/std.cpp | 4 +- src/editors/PPEditor/stdafx.h | 2 +- 35 files changed, 1357 insertions(+), 1154 deletions(-) diff --git a/src/editors/PPEditor/NoiseFGen.cpp b/src/editors/PPEditor/NoiseFGen.cpp index 715c2a265e8..12ffb2a2d62 100644 --- a/src/editors/PPEditor/NoiseFGen.cpp +++ b/src/editors/PPEditor/NoiseFGen.cpp @@ -8,24 +8,27 @@ #pragma package(smart_init) #pragma resource "*.dfm" TNFGen *NFGen; + //--------------------------------------------------------------------------- -__fastcall TNFGen::TNFGen(TComponent* Owner) - : TForm(Owner) -{ -} +__fastcall TNFGen::TNFGen(TComponent *Owner) + : TForm(Owner) {} + //--------------------------------------------------------------------------- void __fastcall TNFGen::Button1Click(TObject *Sender) { - if (Period->Value <= 0.0f || Time->Value <= 0.0f) - { - Application->MessageBox ("Invalid period or time for effect", "Error", MB_OK | MB_ICONSTOP); - return; - } - if (Period->Value >= Time->Value) - { - Application->MessageBox ("Period must be less than time effect", "Error", MB_OK | MB_ICONSTOP); - return; - } + if (Period->Value<=0.0f||Time->Value<=0.0f) + { + Application->MessageBox("Invalid period or time for effect", "Error", MB_OK|MB_ICONSTOP); + return; + } + if (Period->Value>=Time->Value) + { + Application->MessageBox("Period must be less than time effect", "Error", MB_OK|MB_ICONSTOP); + return; + } ModalResult = mrOk; } + //--------------------------------------------------------------------------- + + diff --git a/src/editors/PPEditor/NoiseFGen.h b/src/editors/PPEditor/NoiseFGen.h index f16780532e6..3de4c0a4e1e 100644 --- a/src/editors/PPEditor/NoiseFGen.h +++ b/src/editors/PPEditor/NoiseFGen.h @@ -9,11 +9,12 @@ #include #include #include + //--------------------------------------------------------------------------- class TNFGen : public TForm { -__published: // IDE-managed Components - TMxLabel *RxLabel1; + __published: // IDE-managed Components + TMxLabel*RxLabel1; TMxLabel *RxLabel2; TMxLabel *RxLabel3; TMxLabel *RxLabel4; @@ -25,11 +26,13 @@ class TNFGen : public TForm TButton *Button1; TButton *Button2; void __fastcall Button1Click(TObject *Sender); -private: // User declarations -public: // User declarations - __fastcall TNFGen(TComponent* Owner); +private: // User declarations +public: // User declarations + __fastcall TNFGen(TComponent *Owner); }; + //--------------------------------------------------------------------------- -extern PACKAGE TNFGen *NFGen; +extern PACKAGE TNFGen * NFGen; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/PPEditor/NoiseGen.cpp b/src/editors/PPEditor/NoiseGen.cpp index 88c63a96c8e..1097c64b0b6 100644 --- a/src/editors/PPEditor/NoiseGen.cpp +++ b/src/editors/PPEditor/NoiseGen.cpp @@ -8,42 +8,49 @@ #pragma package(smart_init) #pragma resource "*.dfm" TNGen *NGen; + //--------------------------------------------------------------------------- -__fastcall TNGen::TNGen(TComponent* Owner) - : TForm(Owner) -{ -} +__fastcall TNGen::TNGen(TComponent *Owner) + : TForm(Owner) {} + //--------------------------------------------------------------------------- void __fastcall TNGen::FColorClick(TObject *Sender) { - if (ColorDialog->Execute () == false) return; + if (ColorDialog->Execute()==false) + return; FColor->Color = ColorDialog->Color; - FR->Value = (float)(ColorDialog->Color & 0x0000ff) / 255.0f; - FG->Value = (float)((ColorDialog->Color & 0x00ff00) >> 8) / 255.0f; - FB->Value = (float)((ColorDialog->Color & 0xff0000) >> 16) / 255.0f; + FR->Value = (float)(ColorDialog->Color&0x0000ff)/255.0f; + FG->Value = (float)((ColorDialog->Color&0x00ff00)>>8)/255.0f; + FB->Value = (float)((ColorDialog->Color&0xff0000)>>16)/255.0f; } + //--------------------------------------------------------------------------- void __fastcall TNGen::SColorClick(TObject *Sender) { - if (ColorDialog->Execute () == false) return; + if (ColorDialog->Execute()==false) + return; SColor->Color = ColorDialog->Color; - SR->Value = (float)(ColorDialog->Color & 0x0000ff) / 255.0f; - SG->Value = (float)((ColorDialog->Color & 0x00ff00) >> 8) / 255.0f; - SB->Value = (float)((ColorDialog->Color & 0xff0000) >> 16) / 255.0f; + SR->Value = (float)(ColorDialog->Color&0x0000ff)/255.0f; + SG->Value = (float)((ColorDialog->Color&0x00ff00)>>8)/255.0f; + SB->Value = (float)((ColorDialog->Color&0xff0000)>>16)/255.0f; } + //--------------------------------------------------------------------------- void __fastcall TNGen::Button1Click(TObject *Sender) { - if (Period->Value <= 0.0f || Time->Value <= 0.0f) - { - Application->MessageBox ("Invalid period or time for effect", "Error", MB_OK | MB_ICONSTOP); - return; - } - if (Period->Value >= Time->Value) - { - Application->MessageBox ("Period must be less than time effect", "Error", MB_OK | MB_ICONSTOP); - return; - } + if (Period->Value<=0.0f||Time->Value<=0.0f) + { + Application->MessageBox("Invalid period or time for effect", "Error", MB_OK|MB_ICONSTOP); + return; + } + if (Period->Value>=Time->Value) + { + Application->MessageBox("Period must be less than time effect", "Error", MB_OK|MB_ICONSTOP); + return; + } ModalResult = mrOk; } + //--------------------------------------------------------------------------- + + diff --git a/src/editors/PPEditor/NoiseGen.h b/src/editors/PPEditor/NoiseGen.h index cc1ad7325fe..5c8fedd59f8 100644 --- a/src/editors/PPEditor/NoiseGen.h +++ b/src/editors/PPEditor/NoiseGen.h @@ -10,11 +10,12 @@ #include #include #include + //--------------------------------------------------------------------------- class TNGen : public TForm { -__published: // IDE-managed Components - TGroupBox *GroupBox1; + __published: // IDE-managed Components + TGroupBox*GroupBox1; TMultiObjSpinEdit *FR; TMultiObjSpinEdit *FG; TMultiObjSpinEdit *FB; @@ -41,11 +42,13 @@ class TNGen : public TForm void __fastcall FColorClick(TObject *Sender); void __fastcall SColorClick(TObject *Sender); void __fastcall Button1Click(TObject *Sender); -private: // User declarations -public: // User declarations - __fastcall TNGen(TComponent* Owner); +private: // User declarations +public: // User declarations + __fastcall TNGen(TComponent *Owner); }; + //--------------------------------------------------------------------------- -extern PACKAGE TNGen *NGen; +extern PACKAGE TNGen * NGen; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/PPEditor/PPEditor.vcxproj b/src/editors/PPEditor/PPEditor.vcxproj index ade81f50ad6..ca28266c922 100644 --- a/src/editors/PPEditor/PPEditor.vcxproj +++ b/src/editors/PPEditor/PPEditor.vcxproj @@ -47,6 +47,7 @@ + diff --git a/src/editors/PPEditor/PPEditor.vcxproj.filters b/src/editors/PPEditor/PPEditor.vcxproj.filters index 23cf44d9439..a1c66b75ab4 100644 --- a/src/editors/PPEditor/PPEditor.vcxproj.filters +++ b/src/editors/PPEditor/PPEditor.vcxproj.filters @@ -107,5 +107,6 @@ Header Files + \ No newline at end of file diff --git a/src/editors/PPEditor/Postprocess.bpr b/src/editors/PPEditor/Postprocess.bpr index 5fab58b91ce..457159ee599 100644 --- a/src/editors/PPEditor/Postprocess.bpr +++ b/src/editors/PPEditor/Postprocess.bpr @@ -4,15 +4,15 @@ - + diff --git a/src/editors/PPEditor/Postprocess.cpp b/src/editors/PPEditor/Postprocess.cpp index 5b24da8b7bc..3da650f0067 100644 --- a/src/editors/PPEditor/Postprocess.cpp +++ b/src/editors/PPEditor/Postprocess.cpp @@ -24,16 +24,17 @@ USEFORM("float_constructor.cpp", frmConstructor); USEFORM("color.cpp", AddColorForm); USEFORM("single_param.cpp", AddFloatForm); //--------------------------------------------------------------------------- -FILE *g_LogFileHandle = NULL; +FILE *g_LogFileHandle = NULL; + //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- -void log_callback (LPCSTR lpString) +void log_callback(LPCSTR lpString) { if (!g_LogFileHandle) - return; - fprintf (g_LogFileHandle, "%s\n", lpString); + return; + fprintf(g_LogFileHandle, "%s\n", lpString); } @@ -41,33 +42,34 @@ WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { try { - g_LogFileHandle = fopen ("postprocess.log", "wt"); - Core._initialize ("Postprocess editor", log_callback, FALSE); - FS._initialize (CLocatorAPI::flScanAppRoot, 0, 0); - - Application->Initialize(); - Application->CreateForm(__classid(TMainForm), &MainForm); - Application->Run(); - Core._destroy(); - fclose (g_LogFileHandle); - } - catch (Exception &exception) + g_LogFileHandle = fopen("postprocess.log", "wt"); + Core._initialize("Postprocess editor", log_callback, FALSE); + FS._initialize(CLocatorAPI::flScanAppRoot, 0, 0); + + Application->Initialize(); + Application->CreateForm(__classid(TMainForm), &MainForm); + Application->Run(); + Core._destroy(); + fclose(g_LogFileHandle); + } catch (Exception &exception) { - fclose (g_LogFileHandle); - Application->ShowException(&exception); + fclose(g_LogFileHandle); + Application->ShowException(&exception); } catch (...) { - try - { - throw Exception(""); - } - catch (Exception &exception) - { - fclose (g_LogFileHandle); - Application->ShowException(&exception); - } + try + { + throw Exception(""); + } catch (Exception &exception) + { + fclose(g_LogFileHandle); + Application->ShowException(&exception); + } } return 0; } + //--------------------------------------------------------------------------- + + diff --git a/src/editors/PPEditor/Unit6.cpp b/src/editors/PPEditor/Unit6.cpp index b88a98eebd7..7b3d1b92722 100644 --- a/src/editors/PPEditor/Unit6.cpp +++ b/src/editors/PPEditor/Unit6.cpp @@ -11,13 +11,15 @@ #pragma package(smart_init) #pragma resource "*.dfm" TForm6 *Form6; + //--------------------------------------------------------------------------- -__fastcall TForm6::TForm6(TComponent* Owner) +__fastcall TForm6::TForm6(TComponent *Owner) : TForm(Owner) { m_iTag = 0; - AddEntryTemplate (-1); + AddEntryTemplate(-1); } + //--------------------------------------------------------------------------- //__fastcall TForm6::TForm6 (HWND handle) : TForm (handle) //{ @@ -25,9 +27,9 @@ __fastcall TForm6::TForm6(TComponent* Owner) // AddEntryTemplate (-1); //} //--------------------------------------------------------------------------- -void TForm6::AddEntryTemplate (int iInsertAfter) +void TForm6::AddEntryTemplate(int iInsertAfter) { - TForm7 *form = new TForm7 (this); + TForm7*form = new TForm7(this); form->Parent = this; form->Left = 0; form->Tag = m_iTag++; @@ -38,84 +40,93 @@ void TForm6::AddEntryTemplate (int iInsertAfter) form->DeleteButton->OnClick = OnDelButtonClick; vector temp; iInsertAfter++; - if (!m_Entries.size () || m_Entries.size () == (size_t)iInsertAfter) - { - m_Entries.push_back (form); - } + if (!m_Entries.size()||m_Entries.size()==(size_t)iInsertAfter) + { + m_Entries.push_back(form); + } else - { - for (int a = 0; a < (int)m_Entries.size (); a++) - { - if (a == iInsertAfter) - temp.push_back (form); - temp.push_back (m_Entries[a]); - } - m_Entries.assign (temp.begin (), temp.end ()); - } - ResetPositions (); + { + for (int a = 0; a<(int)m_Entries.size(); a++) + { + if (a==iInsertAfter) + temp.push_back(form); + temp.push_back(m_Entries[a]); + } + m_Entries.assign(temp.begin(), temp.end()); + } + ResetPositions(); } + //--------------------------------------------------------------------------- -void TForm6::ResetPositions () +void TForm6::ResetPositions() { int top = 0; - for (size_t a = 0; a < m_Entries.size (); a++) - { + for (size_t a = 0; aLeft = 0; - m_Entries[a]->Top = (m_Entries[a]->Height + 4) * a + Panel2->Height; + m_Entries[a]->Top = (m_Entries[a]->Height+4)*a+Panel2->Height; top = m_Entries[a]->Top; - } - Button1->Top = top + m_Entries[0]->Height + 4; + } + Button1->Top = top+m_Entries[0]->Height+4; Button2->Top = Button1->Top; - if (m_Entries.size () <= 6) - ClientHeight = Button1->Top + Button1->Height; + if (m_Entries.size()<=6) + ClientHeight = Button1->Top+Button1->Height; } + //--------------------------------------------------------------------------- -void __fastcall TForm6::OnAddButtonClick (TObject *Sender) +void __fastcall TForm6::OnAddButtonClick(TObject *Sender) { - int tag = dynamic_cast (Sender)->Tag; - for (size_t a = 0; a < m_Entries.size (); a++) - if (m_Entries[a]->Tag == tag) - { - AddEntryTemplate (a); - return; - } + int tag = dynamic_cast(Sender)->Tag; + for (size_t a = 0; aTag==tag) + { + AddEntryTemplate(a); + return; + } } + //--------------------------------------------------------------------------- -void __fastcall TForm6::OnDelButtonClick (TObject *Sender) +void __fastcall TForm6::OnDelButtonClick(TObject *Sender) { - if (m_Entries.size () == 1) return; - int tag = dynamic_cast (Sender)->Parent->Parent->Tag; - vector::iterator s = m_Entries.begin(), e = m_Entries.end (); - for (; s != e; ++s) - if ((*s)->Tag == tag) - { - TForm7 *form = (*s); - delete form; - m_Entries.erase (s); - RecalcSize (); - return; - } + if (m_Entries.size()==1) + return; + int tag = dynamic_cast(Sender)->Parent->Parent->Tag; + vector::iterator s = m_Entries.begin(), e = m_Entries.end(); + for (; s!=e; ++s) + if ((*s)->Tag==tag) + { + TForm7*form = (*s); + delete form; + m_Entries.erase(s); + RecalcSize(); + return; + } } + //--------------------------------------------------------------------------- -void TForm6::RecalcSize () +void TForm6::RecalcSize() { int top; - for (int a = 0; a < (int)m_Entries.size (); a++) - { - m_Entries[a]->Top = a * m_Entries[a]->Height + 2; + for (int a = 0; a<(int)m_Entries.size(); a++) + { + m_Entries[a]->Top = a*m_Entries[a]->Height+2; top = m_Entries[a]->Top; - } - Button1->Top = top + m_Entries[0]->Height + 4; + } + Button1->Top = top+m_Entries[0]->Height+4; Button2->Top = Button1->Top; - if (m_Entries.size () <= 6) - ClientHeight = Button1->Top + Button1->Height; + if (m_Entries.size()<=6) + ClientHeight = Button1->Top+Button1->Height; } + //--------------------------------------------------------------------------- void __fastcall TForm6::Panel3Click(TObject *Sender) { - if (ColorDialog->Execute () == false) return; + if (ColorDialog->Execute()==false) + return; Panel3->Color = ColorDialog->Color; m_InitColor = Panel3->Color; } + //--------------------------------------------------------------------------- + diff --git a/src/editors/PPEditor/Unit6.h b/src/editors/PPEditor/Unit6.h index a8adc9e15ed..96038f0d57f 100644 --- a/src/editors/PPEditor/Unit6.h +++ b/src/editors/PPEditor/Unit6.h @@ -20,8 +20,8 @@ using namespace std; //--------------------------------------------------------------------------- class TForm6 : public TForm { -__published: // IDE-managed Components - TButton *Button1; + __published: // IDE-managed Components + TButton*Button1; TButton *Button2; TColorDialog *ColorDialog; TOpenDialog *OpenDialog; @@ -30,22 +30,24 @@ class TForm6 : public TForm TLabel *Label1; TPanel *Panel3; void __fastcall Panel3Click(TObject *Sender); -private: // User declarations - void RecalcSize (); - void ResetPositions (); - int m_iTag; -public: // User declarations - void AddEntryTemplate (int iInsertAfter); - TColor m_InitColor; - vector m_Entries; - __fastcall TForm6(TComponent* Owner); -// __fastcall TForm6 (HWND handle); - void __fastcall OnAddButtonClick (TObject *Sender); - void __fastcall OnDelButtonClick (TObject *Sender); - void __fastcall SaveData (FILE *file); - void __fastcall LoadData (FILE *file); +private: // User declarations + void RecalcSize(); + void ResetPositions(); + int m_iTag; +public: // User declarations + void AddEntryTemplate(int iInsertAfter); + TColor m_InitColor; + vector m_Entries; + __fastcall TForm6(TComponent *Owner); + // __fastcall TForm6 (HWND handle); + void __fastcall OnAddButtonClick(TObject *Sender); + void __fastcall OnDelButtonClick(TObject *Sender); + void __fastcall SaveData(FILE *file); + void __fastcall LoadData(FILE *file); }; + //--------------------------------------------------------------------------- -extern PACKAGE TForm6 *Form6; +extern PACKAGE TForm6 * Form6; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/PPEditor/Unit7.cpp b/src/editors/PPEditor/Unit7.cpp index f471602db6b..67cf7aa4004 100644 --- a/src/editors/PPEditor/Unit7.cpp +++ b/src/editors/PPEditor/Unit7.cpp @@ -8,8 +8,9 @@ #pragma package(smart_init) #pragma resource "*.dfm" TForm7 *Form7; + //--------------------------------------------------------------------------- -__fastcall TForm7::TForm7(TComponent* Owner) +__fastcall TForm7::TForm7(TComponent *Owner) : TForm(Owner) { ColorPanel->Color = (TColor)0; @@ -19,16 +20,21 @@ __fastcall TForm7::TForm7(TComponent* Owner) tg = cg = bg = 0.0f; tb = cb = bb = 0.0f; } + //--------------------------------------------------------------------------- void __fastcall TForm7::ColorPanelClick(TObject *Sender) { - if (ColorDialog->Execute() == false) return; + if (ColorDialog->Execute()==false) + return; ColorPanel->Color = ColorDialog->Color; } + //--------------------------------------------------------------------------- void __fastcall TForm7::LinearFuncButtonClick(TObject *Sender) { - m_iFunction = dynamic_cast (Sender)->Tag; + m_iFunction = dynamic_cast(Sender)->Tag; } + //--------------------------------------------------------------------------- + diff --git a/src/editors/PPEditor/Unit7.h b/src/editors/PPEditor/Unit7.h index 34108fda0a2..3c4bbfe476a 100644 --- a/src/editors/PPEditor/Unit7.h +++ b/src/editors/PPEditor/Unit7.h @@ -14,11 +14,12 @@ #include #include #include + //--------------------------------------------------------------------------- class TForm7 : public TForm { -__published: // IDE-managed Components - TPanel *Panel1; + __published: // IDE-managed Components + TPanel*Panel1; TMultiObjSpinEdit *WorkTime; TPanel *ColorPanel; TSpeedButton *AddButton; @@ -27,15 +28,17 @@ class TForm7 : public TForm TImageList *ImageList; void __fastcall ColorPanelClick(TObject *Sender); void __fastcall LinearFuncButtonClick(TObject *Sender); -private: // User declarations -public: // User declarations - int m_iFunction; - float tr, cr, br; - float tg, cg, bg; - float tb, cb, bb; - __fastcall TForm7(TComponent* Owner); +private: // User declarations +public: // User declarations + int m_iFunction; + float tr, cr, br; + float tg, cg, bg; + float tb, cb, bb; + __fastcall TForm7(TComponent *Owner); }; + //--------------------------------------------------------------------------- -extern PACKAGE TForm7 *Form7; +extern PACKAGE TForm7 * Form7; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/PPEditor/Unit8.cpp b/src/editors/PPEditor/Unit8.cpp index c5e1cedb9d5..2bc35f25992 100644 --- a/src/editors/PPEditor/Unit8.cpp +++ b/src/editors/PPEditor/Unit8.cpp @@ -8,17 +8,19 @@ #pragma package(smart_init) #pragma resource "*.dfm" TForm8 *Form8; + //--------------------------------------------------------------------------- -__fastcall TForm8::TForm8(TComponent* Owner) +__fastcall TForm8::TForm8(TComponent *Owner) : TForm(Owner) { m_iTag = 0; - AddEntryTemplate (-1); + AddEntryTemplate(-1); } + //--------------------------------------------------------------------------- -void TForm8::AddEntryTemplate (int iInsertAfter) +void TForm8::AddEntryTemplate(int iInsertAfter) { - TForm9 *form = new TForm9 (this); + TForm9*form = new TForm9(this); form->Parent = this; form->Left = 0; form->Tag = m_iTag++; @@ -29,77 +31,84 @@ void TForm8::AddEntryTemplate (int iInsertAfter) form->DeleteButton->OnClick = OnDelButtonClick; vector temp; iInsertAfter++; - if (!m_Entries.size () || (int)m_Entries.size () == iInsertAfter) - { - m_Entries.push_back (form); - } + if (!m_Entries.size()||(int)m_Entries.size()==iInsertAfter) + { + m_Entries.push_back(form); + } else - { - for (int a = 0; a < (int)m_Entries.size (); a++) - { - if (a == iInsertAfter) - temp.push_back (form); - temp.push_back (m_Entries[a]); - } - m_Entries.assign (temp.begin (), temp.end ()); - } - ResetPositions (); + { + for (int a = 0; a<(int)m_Entries.size(); a++) + { + if (a==iInsertAfter) + temp.push_back(form); + temp.push_back(m_Entries[a]); + } + m_Entries.assign(temp.begin(), temp.end()); + } + ResetPositions(); } + //--------------------------------------------------------------------------- -void TForm8::ResetPositions () +void TForm8::ResetPositions() { int top = 0; - for (size_t a = 0; a < m_Entries.size (); a++) - { + for (size_t a = 0; aLeft = 0; - m_Entries[a]->Top = (m_Entries[a]->Height + 4) * a + Panel2->Height; + m_Entries[a]->Top = (m_Entries[a]->Height+4)*a+Panel2->Height; top = m_Entries[a]->Top; - } - Button1->Top = top + m_Entries[0]->Height + 4; + } + Button1->Top = top+m_Entries[0]->Height+4; Button2->Top = Button1->Top; - if (m_Entries.size () <= 6) - ClientHeight = Button1->Top + Button1->Height; + if (m_Entries.size()<=6) + ClientHeight = Button1->Top+Button1->Height; } + //--------------------------------------------------------------------------- -void __fastcall TForm8::OnAddButtonClick (TObject *Sender) +void __fastcall TForm8::OnAddButtonClick(TObject *Sender) { - int tag = dynamic_cast (Sender)->Tag; - for (size_t a = 0; a < m_Entries.size (); a++) - if (m_Entries[a]->Tag == tag) - { - AddEntryTemplate (a); - return; - } + int tag = dynamic_cast(Sender)->Tag; + for (size_t a = 0; aTag==tag) + { + AddEntryTemplate(a); + return; + } } + //--------------------------------------------------------------------------- -void __fastcall TForm8::OnDelButtonClick (TObject *Sender) +void __fastcall TForm8::OnDelButtonClick(TObject *Sender) { - if (m_Entries.size () == 1) return; - int tag = dynamic_cast (Sender)->Parent->Parent->Tag; - vector::iterator s = m_Entries.begin(), e = m_Entries.end (); - for (; s != e; ++s) - if ((*s)->Tag == tag) - { - TForm9 *form = (*s); - delete form; - m_Entries.erase (s); - RecalcSize (); - return; - } + if (m_Entries.size()==1) + return; + int tag = dynamic_cast(Sender)->Parent->Parent->Tag; + vector::iterator s = m_Entries.begin(), e = m_Entries.end(); + for (; s!=e; ++s) + if ((*s)->Tag==tag) + { + TForm9*form = (*s); + delete form; + m_Entries.erase(s); + RecalcSize(); + return; + } } + //--------------------------------------------------------------------------- -void TForm8::RecalcSize () +void TForm8::RecalcSize() { int top; - for (int a = 0; a < (int)m_Entries.size (); a++) - { - m_Entries[a]->Top = a * m_Entries[a]->Height + 2; + for (int a = 0; a<(int)m_Entries.size(); a++) + { + m_Entries[a]->Top = a*m_Entries[a]->Height+2; top = m_Entries[a]->Top; - } - Button1->Top = top + m_Entries[0]->Height + 4; + } + Button1->Top = top+m_Entries[0]->Height+4; Button2->Top = Button1->Top; - if (m_Entries.size () <= 6) - ClientHeight = Button1->Top + Button1->Height; + if (m_Entries.size()<=6) + ClientHeight = Button1->Top+Button1->Height; } + //--------------------------------------------------------------------------- + diff --git a/src/editors/PPEditor/Unit8.h b/src/editors/PPEditor/Unit8.h index cc90dda925f..7740d637043 100644 --- a/src/editors/PPEditor/Unit8.h +++ b/src/editors/PPEditor/Unit8.h @@ -17,29 +17,32 @@ #include using namespace std; + //--------------------------------------------------------------------------- class TForm8 : public TForm { -__published: // IDE-managed Components - TButton *Button1; + __published: // IDE-managed Components + TButton*Button1; TButton *Button2; TOpenDialog *OpenDialog; TSaveDialog *SaveDialog; TPanel *Panel2; TLabel *Label1; TMultiObjSpinEdit *InitValue; -private: // User declarations - void AddEntryTemplate (int iInsertAfter); - void RecalcSize (); - void ResetPositions (); - int m_iTag; -public: // User declarations - vector m_Entries; - __fastcall TForm8(TComponent* Owner); - void __fastcall OnAddButtonClick (TObject *Sender); - void __fastcall OnDelButtonClick (TObject *Sender); +private: // User declarations + void AddEntryTemplate(int iInsertAfter); + void RecalcSize(); + void ResetPositions(); + int m_iTag; +public: // User declarations + vector m_Entries; + __fastcall TForm8(TComponent *Owner); + void __fastcall OnAddButtonClick(TObject *Sender); + void __fastcall OnDelButtonClick(TObject *Sender); }; + //--------------------------------------------------------------------------- -extern PACKAGE TForm8 *Form8; +extern PACKAGE TForm8 * Form8; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/PPEditor/Unit9.cpp b/src/editors/PPEditor/Unit9.cpp index 3737500f0fe..d12af476f20 100644 --- a/src/editors/PPEditor/Unit9.cpp +++ b/src/editors/PPEditor/Unit9.cpp @@ -8,12 +8,14 @@ #pragma package(smart_init) #pragma resource "*.dfm" TForm9 *Form9; + //--------------------------------------------------------------------------- -__fastcall TForm9::TForm9(TComponent* Owner) +__fastcall TForm9::TForm9(TComponent *Owner) : TForm(Owner) { ClientHeight = Panel1->Height; - } + //--------------------------------------------------------------------------- + diff --git a/src/editors/PPEditor/Unit9.h b/src/editors/PPEditor/Unit9.h index 4981e613273..6407bf5a6df 100644 --- a/src/editors/PPEditor/Unit9.h +++ b/src/editors/PPEditor/Unit9.h @@ -13,21 +13,24 @@ #include #include #include + //--------------------------------------------------------------------------- class TForm9 : public TForm { -__published: // IDE-managed Components - TPanel *Panel1; + __published: // IDE-managed Components + TPanel*Panel1; TMultiObjSpinEdit *WorkTime; TMultiObjSpinEdit *Value; TSpeedButton *AddButton; TSpeedButton *DeleteButton; TImageList *ImageList; -private: // User declarations -public: // User declarations - __fastcall TForm9(TComponent* Owner); +private: // User declarations +public: // User declarations + __fastcall TForm9(TComponent *Owner); }; + //--------------------------------------------------------------------------- -extern PACKAGE TForm9 *Form9; +extern PACKAGE TForm9 * Form9; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/PPEditor/base.h b/src/editors/PPEditor/base.h index 72445e56b28..c2405f8b755 100644 --- a/src/editors/PPEditor/base.h +++ b/src/editors/PPEditor/base.h @@ -1,26 +1,37 @@ #ifndef BaseH #define BaseH -//#include +//#include #include "PostprocessAnimator.h" + //#include "single_param.h" -enum{tAddColor=0,tBaseColor=1,tGray=2,tDuality=3,tNoise=4,tBlur=5,tColorMap=6}; +enum +{ + tAddColor=0, + tBaseColor=1, + tGray=2, + tDuality=3, + tNoise=4, + tBlur=5, + tColorMap=6 +}; class TPPPropEditor { public: - virtual TForm* GetForm () =0; - virtual void Clear () =0; - virtual void ShowCurrent (u32 keyIdx) =0; - virtual _pp_params GetTimeChannel () =0; - virtual bool DrawChannel (_pp_params) =0; - virtual void Lock (bool b) =0; - virtual void AddNew (u32 keyIdx) =0; - virtual void Remove (u32 keyIdx) =0; - virtual void RemoveAllKeys () =0; - virtual void CreateKey (float t) =0; + virtual TForm *GetForm() =0; + virtual void Clear() =0; + virtual void ShowCurrent(u32 keyIdx) =0; + virtual _pp_params GetTimeChannel() =0; + virtual bool DrawChannel(_pp_params) =0; + virtual void Lock(bool b) =0; + virtual void AddNew(u32 keyIdx) =0; + virtual void Remove(u32 keyIdx) =0; + virtual void RemoveAllKeys() =0; + virtual void CreateKey(float t) =0; }; #endif + diff --git a/src/editors/PPEditor/color.cpp b/src/editors/PPEditor/color.cpp index 5618d7c41e7..b7cdefd3850 100644 --- a/src/editors/PPEditor/color.cpp +++ b/src/editors/PPEditor/color.cpp @@ -9,46 +9,47 @@ #pragma resource "*.dfm" //--------------------------------------------------------------------------- -__fastcall TAddColorForm::TAddColorForm(TComponent* Owner, _pp_params p) - : TForm(Owner),m_pp_params(p),m_bLocked(false) +__fastcall TAddColorForm::TAddColorForm(TComponent *Owner, _pp_params p) + : TForm(Owner), m_pp_params(p), m_bLocked(false) { - if(m_pp_params==pp_base_color) + if (m_pp_params==pp_base_color) { - RedValue->MinValue = -1.0f; - GreenValue->MinValue = -1.0f; - BlueValue->MinValue = -1.0f; - - RedValue->MaxValue = 1.0f; - GreenValue->MaxValue = 1.0f; - BlueValue->MaxValue = 1.0f; - }else - if(m_pp_params==pp_add_color) + RedValue->MinValue = -1.0f; + GreenValue->MinValue = -1.0f; + BlueValue->MinValue = -1.0f; + + RedValue->MaxValue = 1.0f; + GreenValue->MaxValue = 1.0f; + BlueValue->MaxValue = 1.0f; + } + else if (m_pp_params==pp_add_color) { - RedValue->MinValue = -1.0f; - GreenValue->MinValue = -1.0f; - BlueValue->MinValue = -1.0f; - - RedValue->MaxValue = 1.0f; - GreenValue->MaxValue = 1.0f; - BlueValue->MaxValue = 1.0f; - }else - if(m_pp_params==pp_gray_color) + RedValue->MinValue = -1.0f; + GreenValue->MinValue = -1.0f; + BlueValue->MinValue = -1.0f; + + RedValue->MaxValue = 1.0f; + GreenValue->MaxValue = 1.0f; + BlueValue->MaxValue = 1.0f; + } + else if (m_pp_params==pp_gray_color) { labelIntensity->Visible = true; IntensityValue->Visible = true; - - RedValue->MinValue = -1.0f; - GreenValue->MinValue = -1.0f; - BlueValue->MinValue = -1.0f; - - RedValue->MaxValue = 1.0f; - GreenValue->MaxValue = 1.0f; - BlueValue->MaxValue = 1.0f; - - IntensityValue->MinValue = 0.0f; - IntensityValue->MaxValue = 1.0f; + + RedValue->MinValue = -1.0f; + GreenValue->MinValue = -1.0f; + BlueValue->MinValue = -1.0f; + + RedValue->MaxValue = 1.0f; + GreenValue->MaxValue = 1.0f; + BlueValue->MaxValue = 1.0f; + + IntensityValue->MinValue = 0.0f; + IntensityValue->MaxValue = 1.0f; } } + //--------------------------------------------------------------------------- /* { @@ -66,217 +67,224 @@ __fastcall TAddColorForm::TAddColorForm(TComponent* Owner, _pp_params p) cparam->add_value (time, GreenValue->Value, 1); cparam->add_value (time, BlueValue->Value, 2); - if(m_pp_params==pp_gray_color) + if(m_pp_params==pp_gray_color) { - cparam = MainForm->m_Animator->GetParam (pp_gray_value); - cparam->delete_value (time_prev); - cparam->add_value (time, IntensityValue->Value, 0); + cparam = MainForm->m_Animator->GetParam (pp_gray_value); + cparam->delete_value (time_prev); + cparam->add_value (time, IntensityValue->Value, 0); } MainForm->PointListSetTime (MainForm->PointList->ItemIndex, time); - MainForm->UpdateGraph (); + MainForm->UpdateGraph (); } */ void __fastcall TAddColorForm::TimeValueExit(TObject *Sender) { - if (m_bLocked) return; - if (MainForm->PointList->ItemIndex == -1) return; - TMultiObjSpinEdit* spin = dynamic_cast(Sender); - if(spin->Color == clLime) + if (m_bLocked) + return; + if (MainForm->PointList->ItemIndex==-1) + return; + TMultiObjSpinEdit *spin = dynamic_cast(Sender); + if (spin->Color==clLime) { - if(TimeValue->ValueMinValue) - TimeValue->Value=TimeValue->MinValue; - if(TimeValue->Value>TimeValue->MaxValue) - TimeValue->Value=TimeValue->MaxValue; + if (TimeValue->ValueMinValue) + TimeValue->Value = TimeValue->MinValue; + if (TimeValue->Value>TimeValue->MaxValue) + TimeValue->Value = TimeValue->MaxValue; - CPostProcessParam* cparam = MainForm->m_Animator->GetParam (GetTimeChannel()); + CPostProcessParam *cparam = MainForm->m_Animator->GetParam(GetTimeChannel()); - float time_prev = cparam->get_key_time(MainForm->PointList->ItemIndex); - cparam->delete_value (time_prev); - - float time = TimeValue->Value; + float time_prev = cparam->get_key_time(MainForm->PointList->ItemIndex); + cparam->delete_value(time_prev); - cparam->add_value (time, RedValue->Value, 0); - cparam->add_value (time, GreenValue->Value, 1); - cparam->add_value (time, BlueValue->Value, 2); + float time = TimeValue->Value; - if(m_pp_params==pp_gray_color) + cparam->add_value(time, RedValue->Value, 0); + cparam->add_value(time, GreenValue->Value, 1); + cparam->add_value(time, BlueValue->Value, 2); + + if (m_pp_params==pp_gray_color) { - cparam = MainForm->m_Animator->GetParam (pp_gray_value); - cparam->delete_value (time_prev); - cparam->add_value (time, IntensityValue->Value, 0); + cparam = MainForm->m_Animator->GetParam(pp_gray_value); + cparam->delete_value(time_prev); + cparam->add_value(time, IntensityValue->Value, 0); } - MainForm->PointListSetTime (MainForm->PointList->ItemIndex, time); - MainForm->UpdateGraph (); - TimeValue->Color = clWindow; - RedValue->Color = clWindow; - GreenValue->Color = clWindow; - BlueValue->Color = clWindow; - IntensityValue->Color = clWindow; + MainForm->PointListSetTime(MainForm->PointList->ItemIndex, time); + MainForm->UpdateGraph(); + TimeValue->Color = clWindow; + RedValue->Color = clWindow; + GreenValue->Color = clWindow; + BlueValue->Color = clWindow; + IntensityValue->Color = clWindow; } } void __fastcall TAddColorForm::CnahgeParam(TObject *Sender) { - if (m_bLocked) return; - if (MainForm->PointList->ItemIndex == -1) return; - TMultiObjSpinEdit* spin = dynamic_cast(Sender); + if (m_bLocked) + return; + if (MainForm->PointList->ItemIndex==-1) + return; + TMultiObjSpinEdit *spin = dynamic_cast(Sender); spin->Color = clLime; } //--------------------------------------------------------------------------- -void TAddColorForm::Clear() +void TAddColorForm::Clear() { Lock(true); - TimeValue->Value = 0.0f; - RedValue->Value = 0.0f; - GreenValue->Value = 0.0f; - BlueValue->Value = 0.0f; - IntensityValue->Value = 0.0f; + TimeValue->Value = 0.0f; + RedValue->Value = 0.0f; + GreenValue->Value = 0.0f; + BlueValue->Value = 0.0f; + IntensityValue->Value = 0.0f; Lock(false); } void TAddColorForm::ShowCurrent(u32 keyIdx) { - if(keyIdx==-1) + if (keyIdx==-1) { - Clear(); + Clear(); return; } - - CPostProcessParam* cparam = MainForm->m_Animator->GetParam (GetTimeChannel()); - float time = cparam->get_key_time(keyIdx); - MainForm->SetMarkerPosition(time); - - if(keyIdx>0) - TimeValue->MinValue = cparam->get_key_time(keyIdx-1)+0.02f; - else - TimeValue->MinValue = 0.0f; - - - if(cparam->get_keys_count()>keyIdx+1) - TimeValue->MaxValue = cparam->get_key_time(keyIdx+1)-0.02f; - else - TimeValue->MaxValue = 1000.0f; - - TimeValue->Value = time; - - float val; - cparam->get_value (time, val, 0); - RedValue->Value = val; - cparam->get_value (time, val, 1); - GreenValue->Value = val; - cparam->get_value (time, val, 2); - BlueValue->Value = val; - if(m_pp_params==pp_gray_color) - { - CPostProcessParam* cparam = MainForm->m_Animator->GetParam (pp_gray_value); - - cparam->get_value (time, val, 0); - IntensityValue->Value = val; - } + + CPostProcessParam *cparam = MainForm->m_Animator->GetParam(GetTimeChannel()); + float time = cparam->get_key_time(keyIdx); + MainForm->SetMarkerPosition(time); + + if (keyIdx>0) + TimeValue->MinValue = cparam->get_key_time(keyIdx-1)+0.02f; + else + TimeValue->MinValue = 0.0f; + + + if (cparam->get_keys_count()>keyIdx+1) + TimeValue->MaxValue = cparam->get_key_time(keyIdx+1)-0.02f; + else + TimeValue->MaxValue = 1000.0f; + + TimeValue->Value = time; + + float val; + cparam->get_value(time, val, 0); + RedValue->Value = val; + cparam->get_value(time, val, 1); + GreenValue->Value = val; + cparam->get_value(time, val, 2); + BlueValue->Value = val; + if (m_pp_params==pp_gray_color) + { + CPostProcessParam*cparam = MainForm->m_Animator->GetParam(pp_gray_value); + + cparam->get_value(time, val, 0); + IntensityValue->Value = val; + } } -bool TAddColorForm::DrawChannel(_pp_params p) +bool TAddColorForm::DrawChannel(_pp_params p) { - switch(m_pp_params) + switch (m_pp_params) { - case pp_add_color: return (p==pp_add_color); - case pp_base_color: return (p==pp_base_color); - case pp_gray_color: return (p==pp_gray_color)||(p==pp_gray_value); - default:R_ASSERT(0); + case pp_add_color: return (p==pp_add_color); + case pp_base_color: return (p==pp_base_color); + case pp_gray_color: return (p==pp_gray_color)||(p==pp_gray_value); + default: R_ASSERT(0); } return false; }; void TAddColorForm::AddNew(u32 keyIdx) { - CPostProcessParam* cparam = MainForm->m_Animator->GetParam (GetTimeChannel()); + CPostProcessParam *cparam = MainForm->m_Animator->GetParam(GetTimeChannel()); - float time = (keyIdx!=-1)?cparam->get_key_time(keyIdx):0.0f; - - MainForm->SetMarkerPosition (time); - time += 0.01f; - CreateKey (time); + float time = (keyIdx!=-1) ? cparam->get_key_time(keyIdx) : 0.0f; + MainForm->SetMarkerPosition(time); + time += 0.01f; + CreateKey(time); } void TAddColorForm::Remove(u32 keyIdx) { - if(keyIdx==-1) return; - - CPostProcessParam* cparam = MainForm->m_Animator->GetParam (GetTimeChannel()); - - float time = cparam->get_key_time(keyIdx); - - cparam->delete_value (time); - - if(m_pp_params==pp_gray_color) - { - cparam = MainForm->m_Animator->GetParam (pp_gray_value); - cparam->delete_value (time); - } + if (keyIdx==-1) + return; + + CPostProcessParam *cparam = MainForm->m_Animator->GetParam(GetTimeChannel()); + + float time = cparam->get_key_time(keyIdx); + + cparam->delete_value(time); + + if (m_pp_params==pp_gray_color) + { + cparam = MainForm->m_Animator->GetParam(pp_gray_value); + cparam->delete_value(time); + } } void TAddColorForm::RemoveAllKeys() { - CPostProcessParam* cparam = MainForm->m_Animator->GetParam (GetTimeChannel()); - cparam->clear_all_keys (); - - if(m_pp_params==pp_gray_color) - { - cparam = MainForm->m_Animator->GetParam (pp_gray_value); - cparam->clear_all_keys (); - } + CPostProcessParam *cparam = MainForm->m_Animator->GetParam(GetTimeChannel()); + cparam->clear_all_keys(); + + if (m_pp_params==pp_gray_color) + { + cparam = MainForm->m_Animator->GetParam(pp_gray_value); + cparam->clear_all_keys(); + } } -void TAddColorForm::CreateKey(float time) + +void TAddColorForm::CreateKey(float time) { - CPostProcessParam* cparam = MainForm->m_Animator->GetParam (GetTimeChannel()); - - cparam->add_value (time, 0.0f, 0); - cparam->add_value (time, 0.0f, 1); - cparam->add_value (time, 0.0f, 2); - - - if(m_pp_params==pp_gray_color) - { - cparam = MainForm->m_Animator->GetParam (pp_gray_value); - cparam->add_value (time, 0.0f, 0); - } + CPostProcessParam *cparam = MainForm->m_Animator->GetParam(GetTimeChannel()); + + cparam->add_value(time, 0.0f, 0); + cparam->add_value(time, 0.0f, 1); + cparam->add_value(time, 0.0f, 2); + + + if (m_pp_params==pp_gray_color) + { + cparam = MainForm->m_Animator->GetParam(pp_gray_value); + cparam->add_value(time, 0.0f, 0); + } } void __fastcall TAddColorForm::ColorClick(TObject *Sender) { - float l = _abs((float)RedValue->MaxValue - (float)RedValue->MinValue); + float l = _abs((float)RedValue->MaxValue-(float)RedValue->MinValue); + + float kl = l/255.0f; - float kl = l/255.0f; + ColorDialog->Color = color_rgba((BlueValue->Value-BlueValue->MinValue)/kl, + (GreenValue->Value-GreenValue->MinValue)/kl, + (RedValue->Value-RedValue->MinValue)/kl, + 0.0f); + if (ColorDialog->Execute()) + { + TColor clr = ColorDialog->Color; - ColorDialog->Color = color_rgba( (BlueValue->Value - BlueValue->MinValue)/kl , - (GreenValue->Value - GreenValue->MinValue)/kl, - (RedValue->Value - RedValue->MinValue)/kl, - 0.0f); - if (ColorDialog->Execute() ) - { - TColor clr = ColorDialog->Color; - - RedValue->Value = RedValue->MinValue + color_get_B(clr)*kl; - GreenValue->Value = GreenValue->MinValue + color_get_G(clr)*kl; - BlueValue->Value = BlueValue->MinValue + color_get_R(clr)*kl; // /255 + RedValue->Value = RedValue->MinValue+color_get_B(clr)*kl; + GreenValue->Value = GreenValue->MinValue+color_get_G(clr)*kl; + BlueValue->Value = BlueValue->MinValue+color_get_R(clr)*kl; // /255 - TimeValueExit (RedValue); - } + TimeValueExit(RedValue); + } } //--------------------------------------------------------------------------- void __fastcall TAddColorForm::TimeValueKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift) + TShiftState Shift) { - if(Key==VK_RETURN) - TimeValueExit(Sender); + if (Key==VK_RETURN) + TimeValueExit(Sender); } + //--------------------------------------------------------------------------- + diff --git a/src/editors/PPEditor/color.h b/src/editors/PPEditor/color.h index 2ac3cccacaf..a6bbbfcc6ba 100644 --- a/src/editors/PPEditor/color.h +++ b/src/editors/PPEditor/color.h @@ -17,42 +17,57 @@ //--------------------------------------------------------------------------- class TAddColorForm : public TForm, public TPPPropEditor { -__published: // IDE-managed Components - TGroupBox *GroupBox1; + __published: // IDE-managed Components + TGroupBox*GroupBox1; TMultiObjSpinEdit *RedValue; TMxLabel *RxLabel2; TPanel *Color; TColorDialog *ColorDialog; - TMxLabel *RxLabel6; - TMultiObjSpinEdit *GreenValue; - TMxLabel *RxLabel10; - TMultiObjSpinEdit *BlueValue; - TMxLabel *labelIntensity; - TMultiObjSpinEdit *IntensityValue; - TMxLabel *MxLabel1; - TMultiObjSpinEdit *TimeValue; + TMxLabel *RxLabel6; + TMultiObjSpinEdit *GreenValue; + TMxLabel *RxLabel10; + TMultiObjSpinEdit *BlueValue; + TMxLabel *labelIntensity; + TMultiObjSpinEdit *IntensityValue; + TMxLabel *MxLabel1; + TMultiObjSpinEdit *TimeValue; void __fastcall CnahgeParam(TObject *Sender); - void __fastcall ColorClick(TObject *Sender); - void __fastcall TimeValueExit(TObject *Sender); - void __fastcall TimeValueKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift); -private: // User declarations - void UpdateColor (); - bool m_bLocked; -public: // User declarations - virtual void Lock (bool b){m_bLocked=b;} - _pp_params m_pp_params; - - __fastcall TAddColorForm(TComponent* Owner, _pp_params p); - - virtual void ShowCurrent (u32 keyIdx); - virtual _pp_params GetTimeChannel () {return m_pp_params;}; - virtual bool DrawChannel (_pp_params p);; - virtual void Clear (); - virtual TForm* GetForm () {return this;}; - virtual void AddNew (u32 keyIdx); - virtual void Remove (u32 keyIdx); - virtual void RemoveAllKeys (); - virtual void CreateKey (float t); + void __fastcall ColorClick(TObject *Sender); + void __fastcall TimeValueExit(TObject *Sender); + void __fastcall TimeValueKeyDown(TObject *Sender, WORD &Key, + TShiftState Shift); +private: // User declarations + void UpdateColor(); + bool m_bLocked; +public: // User declarations + virtual void Lock(bool b) + { + m_bLocked = b; + } + + _pp_params m_pp_params; + + __fastcall TAddColorForm(TComponent *Owner, _pp_params p); + + virtual void ShowCurrent(u32 keyIdx); + + virtual _pp_params GetTimeChannel() + { + return m_pp_params; + }; + + virtual bool DrawChannel(_pp_params p);; + virtual void Clear(); + + virtual TForm *GetForm() + { + return this; + }; + + virtual void AddNew(u32 keyIdx); + virtual void Remove(u32 keyIdx); + virtual void RemoveAllKeys(); + virtual void CreateKey(float t); }; #endif + diff --git a/src/editors/PPEditor/effect.cpp b/src/editors/PPEditor/effect.cpp index de541d57253..00ce92da11f 100644 --- a/src/editors/PPEditor/effect.cpp +++ b/src/editors/PPEditor/effect.cpp @@ -9,32 +9,35 @@ //--------------------------------------------------------------------------- - Effect::Effect (Graphics::TBitmap *host) +Effect::Effect(Graphics::TBitmap *host) { m_Host = host; - m_BaseColor = new ColorParam (host); - m_AddColor = new ColorParam (host); - m_GrayColor = new ColorParam (host); + m_BaseColor = new ColorParam(host); + m_AddColor = new ColorParam(host); + m_GrayColor = new ColorParam(host); m_Created = false; m_Edit = ee_none; m_Time = 0.0f; } + //--------------------------------------------------------------------------- - Effect::~Effect () +Effect::~Effect() { delete m_GrayColor; delete m_AddColor; delete m_BaseColor; } + //--------------------------------------------------------------------------- -void Effect::clear () +void Effect::clear() { - m_BaseColor->clear (); - m_AddColor->clear (); - m_GrayColor->clear (); + m_BaseColor->clear(); + m_AddColor->clear(); + m_GrayColor->clear(); } + //--------------------------------------------------------------------------- -void Effect::create (float time) +void Effect::create(float time) { m_BaseColor->create(time); m_AddColor->create(time); @@ -42,31 +45,38 @@ void Effect::create (float time) m_Time = time; m_Created = true; } + //--------------------------------------------------------------------------- -void Effect::draw () +void Effect::draw() { - if (m_Created == false) return; - m_BaseColor->draw (); - m_AddColor->draw (); - m_GrayColor->draw (); + if (m_Created==false) + return; + m_BaseColor->draw(); + m_AddColor->draw(); + m_GrayColor->draw(); } + //--------------------------------------------------------------------------- -void Effect::add_point (int _xpos, int _ypos) +void Effect::add_point(int _xpos, int _ypos) { - if (m_Edit == ee_none) return; - float ftime = (float)_xpos / (float)m_Host->Width; - float fvalue = (float)_ypos - (float)m_Host->Height * 0.5f; + if (m_Edit==ee_none) + return; + float ftime = (float)_xpos/(float)m_Host->Width; + float fvalue = (float)_ypos-(float)m_Host->Height*0.5f; switch (m_Edit) - { - case ee_base_color: - break; - case ee_add_color: - break; - case ee_gray_color: - break; - } + { + case ee_base_color: + break; + case ee_add_color: + break; + case ee_gray_color: + break; + } } + //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- + + diff --git a/src/editors/PPEditor/effect.h b/src/editors/PPEditor/effect.h index 63ba8b411a1..b0fc8830b46 100644 --- a/src/editors/PPEditor/effect.h +++ b/src/editors/PPEditor/effect.h @@ -3,37 +3,52 @@ #ifndef effectH #define effectH #include "color_param.h" + //--------------------------------------------------------------------------- typedef enum _edit_effect { - ee_none = 0, - ee_base_color = 1, - ee_add_color = 2, - ee_gray_color = 3, - ee_force_dword = 0x7fffffff + ee_none = 0, + ee_base_color = 1, + ee_add_color = 2, + ee_gray_color = 3, + ee_force_dword = 0x7fffffff } edit_effect; class Effect { protected: - Graphics::TBitmap *m_Host; - ColorParam *m_BaseColor; - ColorParam *m_AddColor; - ColorParam *m_GrayColor; - bool m_Created; - edit_effect m_Edit; - float m_Time; + Graphics::TBitmap *m_Host; + ColorParam *m_BaseColor; + ColorParam *m_AddColor; + ColorParam *m_GrayColor; + bool m_Created; + edit_effect m_Edit; + float m_Time; public: - Effect (Graphics::TBitmap *host); - ~Effect (); - void clear (); - void create (float time); - void draw (); - ColorParam* get_base_color () { return m_BaseColor; } - ColorParam* get_add_color () { return m_AddColor; } - ColorParam* get_gray_color () { return m_GrayColor; } - void add_point (int _xpos, int _ypos); + Effect(Graphics::TBitmap *host); + ~Effect(); + void clear(); + void create(float time); + void draw(); + + ColorParam *get_base_color() + { + return m_BaseColor; + } + + ColorParam *get_add_color() + { + return m_AddColor; + } + + ColorParam *get_gray_color() + { + return m_GrayColor; + } + + void add_point(int _xpos, int _ypos); }; #endif + diff --git a/src/editors/PPEditor/float_constructor.cpp b/src/editors/PPEditor/float_constructor.cpp index f18eac08d79..7e13768c1eb 100644 --- a/src/editors/PPEditor/float_constructor.cpp +++ b/src/editors/PPEditor/float_constructor.cpp @@ -5,111 +5,119 @@ #pragma package(smart_init) #pragma resource "*.dfm" TfrmConstructor *frmConstructor; + //--------------------------------------------------------------------------- -__fastcall TfrmConstructor::TfrmConstructor(TComponent* Owner) - : TForm(Owner),b_locked(false) +__fastcall TfrmConstructor::TfrmConstructor(TComponent *Owner) + : TForm(Owner), b_locked(false) { - m_iTag = 0; + m_iTag = 0; } + //--------------------------------------------------------------------------- -TfrmTimeConstructor* TfrmConstructor::AddEntryTemplate(int iInsertAfterIdx) +TfrmTimeConstructor *TfrmConstructor::AddEntryTemplate(int iInsertAfterIdx) { - TfrmTimeConstructor* form = new TfrmTimeConstructor (this); - form->Parent = this; - form->Left = 0; - form->Tag = m_iTag++; - form->Visible = true; - form->AddButton->Tag = form->Tag; - form->DeleteButton->Tag = form->Tag; - form->AddButton->OnClick = OnAddButtonClick; + TfrmTimeConstructor*form = new TfrmTimeConstructor(this); + form->Parent = this; + form->Left = 0; + form->Tag = m_iTag++; + form->Visible = true; + form->AddButton->Tag = form->Tag; + form->DeleteButton->Tag = form->Tag; + form->AddButton->OnClick = OnAddButtonClick; form->DeleteButton->OnClick = OnDelButtonClick; - form->WorkTime->OnChange = OnTimeChangeClick; + form->WorkTime->OnChange = OnTimeChangeClick; - if(iInsertAfterIdx==-1) - m_Entries.push_back (form); - else - { - vector::iterator it = m_Entries.begin(); - std::advance(it,iInsertAfterIdx+1); - m_Entries.insert(it,form); - } + if (iInsertAfterIdx==-1) + m_Entries.push_back(form); + else + { + vector::iterator it = m_Entries.begin(); + std::advance(it, iInsertAfterIdx+1); + m_Entries.insert(it, form); + } return form; } + //--------------------------------------------------------------------------- -void TfrmConstructor::UpdatePositions() +void TfrmConstructor::UpdatePositions() { - if(b_locked) return; - float start_time = 0.0f; - for (size_t a = 0; a < m_Entries.size (); ++a) - { - m_Entries[a]->StartTime->Value = start_time; - m_Entries[a]->Left = 0; - m_Entries[a]->Top = (m_Entries[a]->Height + 4) * a; - start_time += m_Entries[a]->WorkTime->Value; - } - ClientHeight = m_Entries.size()*(30+4) + Button1->Height; + if (b_locked) + return; + float start_time = 0.0f; + for (size_t a = 0; aStartTime->Value = start_time; + m_Entries[a]->Left = 0; + m_Entries[a]->Top = (m_Entries[a]->Height+4)*a; + start_time += m_Entries[a]->WorkTime->Value; + } + ClientHeight = m_Entries.size()*(30+4)+Button1->Height; Button1->Top = ClientHeight-Button1->Height; Button2->Top = ClientHeight-Button2->Height; } -void __fastcall TfrmConstructor::OnTimeChangeClick(TObject *Sender) +void __fastcall TfrmConstructor::OnTimeChangeClick(TObject *Sender) { - UpdatePositions(); + UpdatePositions(); } //--------------------------------------------------------------------------- -void __fastcall TfrmConstructor::OnAddButtonClick (TObject *Sender) +void __fastcall TfrmConstructor::OnAddButtonClick(TObject *Sender) { - int tag = dynamic_cast (Sender)->Tag; - for (size_t a = 0; a < m_Entries.size (); a++) - if (m_Entries[a]->Tag == tag) - { - AddEntryTemplate (a); - UpdatePositions (); - return; - } + int tag = dynamic_cast(Sender)->Tag; + for (size_t a = 0; aTag==tag) + { + AddEntryTemplate(a); + UpdatePositions(); + return; + } } + //--------------------------------------------------------------------------- -void __fastcall TfrmConstructor::OnDelButtonClick (TObject *Sender) +void __fastcall TfrmConstructor::OnDelButtonClick(TObject *Sender) { - if (m_Entries.size () == 1) return; - int tag = dynamic_cast (Sender)->Parent->Parent->Tag; - vector::iterator s = m_Entries.begin(), e = m_Entries.end (); - for (; s != e; ++s) - if ((*s)->Tag == tag) - { - TfrmTimeConstructor *form = (*s); - delete form; - m_Entries.erase (s); - UpdatePositions (); - return; - } + if (m_Entries.size()==1) + return; + int tag = dynamic_cast(Sender)->Parent->Parent->Tag; + vector::iterator s = m_Entries.begin(), e = m_Entries.end(); + for (; s!=e; ++s) + if ((*s)->Tag==tag) + { + TfrmTimeConstructor*form = (*s); + delete form; + m_Entries.erase(s); + UpdatePositions(); + return; + } } + //--------------------------------------------------------------------------- -void __fastcall TfrmConstructor::Reset() +void __fastcall TfrmConstructor::Reset() { - vector::iterator it = m_Entries.begin(); - vector::iterator it_e = m_Entries.end (); + vector::iterator it = m_Entries.begin(); + vector::iterator it_e = m_Entries.end(); for (; it!=it_e; ++it) { - TfrmTimeConstructor* form = (*it); - delete form; + TfrmTimeConstructor*form = (*it); + delete form; } - m_Entries.clear (); + m_Entries.clear(); - AddEntryTemplate (-1); + AddEntryTemplate(-1); m_Entries[0]->WorkTime->Value = 0.0f; - } //--------------------------------------------------------------------------- -TfrmTimeConstructor* __fastcall TfrmConstructor::GetEntry(u32 index) +TfrmTimeConstructor * __fastcall TfrmConstructor::GetEntry(u32 index) { - if (index >= m_Entries.size()) - throw Exception ("Float constructor: invalid index"); + if (index>=m_Entries.size()) + throw Exception("Float constructor: invalid index"); return m_Entries[index]; } + //--------------------------------------------------------------------------- + diff --git a/src/editors/PPEditor/float_constructor.h b/src/editors/PPEditor/float_constructor.h index 40867f47ba7..8e2d9d316ea 100644 --- a/src/editors/PPEditor/float_constructor.h +++ b/src/editors/PPEditor/float_constructor.h @@ -16,28 +16,35 @@ #include using namespace std; + //--------------------------------------------------------------------------- class TfrmConstructor : public TForm { -__published: // IDE-managed Components - TButton *Button1; + __published: // IDE-managed Components + TButton*Button1; TButton *Button2; -private: // User declarations - int m_iTag; - bool b_locked; -public: // User declarations - vector m_Entries; - __fastcall TfrmConstructor (TComponent* Owner); - TfrmTimeConstructor* AddEntryTemplate (int iInsertAfter); - void __fastcall OnTimeChangeClick (TObject *Sender); - void __fastcall OnAddButtonClick (TObject *Sender); - void __fastcall OnDelButtonClick (TObject *Sender); - void __fastcall Reset (); - TfrmTimeConstructor* __fastcall GetEntry (u32 index); - void UpdatePositions (); - void Lock (bool b){b_locked=b;} +private: // User declarations + int m_iTag; + bool b_locked; +public: // User declarations + vector m_Entries; + __fastcall TfrmConstructor(TComponent *Owner); + TfrmTimeConstructor *AddEntryTemplate(int iInsertAfter); + void __fastcall OnTimeChangeClick(TObject *Sender); + void __fastcall OnAddButtonClick(TObject *Sender); + void __fastcall OnDelButtonClick(TObject *Sender); + void __fastcall Reset(); + TfrmTimeConstructor * __fastcall GetEntry(u32 index); + void UpdatePositions(); + + void Lock(bool b) + { + b_locked = b; + } }; + //--------------------------------------------------------------------------- -extern PACKAGE TfrmConstructor *frmConstructor; +extern PACKAGE TfrmConstructor * frmConstructor; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/PPEditor/float_param.cpp b/src/editors/PPEditor/float_param.cpp index 0cf2c9bfb8b..cb728d546e3 100644 --- a/src/editors/PPEditor/float_param.cpp +++ b/src/editors/PPEditor/float_param.cpp @@ -8,12 +8,14 @@ #pragma link "MXCtrls" #pragma resource "*.dfm" TfrmTimeConstructor *frmTimeConstructor; + //--------------------------------------------------------------------------- -__fastcall TfrmTimeConstructor::TfrmTimeConstructor(TComponent* Owner) +__fastcall TfrmTimeConstructor::TfrmTimeConstructor(TComponent *Owner) : TForm(Owner) { ClientHeight = Panel1->Height; - } + //--------------------------------------------------------------------------- + diff --git a/src/editors/PPEditor/float_param.h b/src/editors/PPEditor/float_param.h index 06d2fac29ac..7480648cacb 100644 --- a/src/editors/PPEditor/float_param.h +++ b/src/editors/PPEditor/float_param.h @@ -15,23 +15,26 @@ #include #include "multi_edit.hpp" #include "MXCtrls.hpp" + //--------------------------------------------------------------------------- class TfrmTimeConstructor : public TForm { -__published: // IDE-managed Components - TPanel *Panel1; + __published: // IDE-managed Components + TPanel*Panel1; TMultiObjSpinEdit *WorkTime; TSpeedButton *AddButton; TSpeedButton *DeleteButton; - TMxLabel *RxLabel2; - TMxLabel *MxLabel1; - TMultiObjSpinEdit *StartTime; -private: // User declarations -public: // User declarations - float t, c, b; - __fastcall TfrmTimeConstructor(TComponent* Owner); + TMxLabel *RxLabel2; + TMxLabel *MxLabel1; + TMultiObjSpinEdit *StartTime; +private: // User declarations +public: // User declarations + float t, c, b; + __fastcall TfrmTimeConstructor(TComponent *Owner); }; + //--------------------------------------------------------------------------- -extern PACKAGE TfrmTimeConstructor *frmTimeConstructor; +extern PACKAGE TfrmTimeConstructor * frmTimeConstructor; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/PPEditor/main.cpp b/src/editors/PPEditor/main.cpp index 4f9df5bf7d9..876a4146bc2 100644 --- a/src/editors/PPEditor/main.cpp +++ b/src/editors/PPEditor/main.cpp @@ -13,49 +13,50 @@ TMainForm *MainForm; //--------------------------------------------------------------------------- -__fastcall TMainForm::TMainForm(TComponent* Owner) +__fastcall TMainForm::TMainForm(TComponent *Owner) : TForm(Owner) { - frmConstructor = new TfrmConstructor(this); - Image->Picture->Bitmap->Width = Image->Width; - Image->Picture->Bitmap->Height = Image->Height; - - m_Animator = new CPostprocessAnimator (0, false); - m_ActiveShowForm = NULL; - - m_props[tAddColor] = new TAddColorForm(this, pp_add_color); - m_props[tAddColor]->GetForm()->Parent = WorkArea; - m_props[tAddColor]->GetForm()->Visible = false; - - m_props[tBaseColor] = new TAddColorForm(this,pp_base_color); - m_props[tBaseColor]->GetForm()->Parent = WorkArea; + frmConstructor = new TfrmConstructor(this); + Image->Picture->Bitmap->Width = Image->Width; + Image->Picture->Bitmap->Height = Image->Height; + + m_Animator = new CPostprocessAnimator(0, false); + m_ActiveShowForm = NULL; + + m_props[tAddColor] = new TAddColorForm(this, pp_add_color); + m_props[tAddColor]->GetForm()->Parent = WorkArea; + m_props[tAddColor]->GetForm()->Visible = false; + + m_props[tBaseColor] = new TAddColorForm(this, pp_base_color); + m_props[tBaseColor]->GetForm()->Parent = WorkArea; m_props[tBaseColor]->GetForm()->Visible = false; - m_props[tGray] = new TAddColorForm(this,pp_gray_color); - m_props[tGray]->GetForm()->Parent = WorkArea; - m_props[tGray]->GetForm()->Visible = false; + m_props[tGray] = new TAddColorForm(this, pp_gray_color); + m_props[tGray]->GetForm()->Parent = WorkArea; + m_props[tGray]->GetForm()->Visible = false; - m_props[tDuality] = new TAddFloatForm(this,pp_dual_h); - m_props[tDuality]->GetForm()->Parent = WorkArea; - m_props[tDuality]->GetForm()->Visible = false; + m_props[tDuality] = new TAddFloatForm(this, pp_dual_h); + m_props[tDuality]->GetForm()->Parent = WorkArea; + m_props[tDuality]->GetForm()->Visible = false; - m_props[tNoise] = new TAddFloatForm(this,pp_noise_i); - m_props[tNoise]->GetForm()->Parent = WorkArea; - m_props[tNoise]->GetForm()->Visible = false; + m_props[tNoise] = new TAddFloatForm(this, pp_noise_i); + m_props[tNoise]->GetForm()->Parent = WorkArea; + m_props[tNoise]->GetForm()->Visible = false; - m_props[tBlur] = new TAddColorForm(this,pp_gray_color); - m_props[tBlur]->GetForm()->Parent = WorkArea; - m_props[tBlur]->GetForm()->Visible = false; + m_props[tBlur] = new TAddColorForm(this, pp_gray_color); + m_props[tBlur]->GetForm()->Parent = WorkArea; + m_props[tBlur]->GetForm()->Visible = false; - m_props[tColorMap] = new TAddFloatForm(this,pp_cm_influence); - m_props[tColorMap]->GetForm()->Parent = WorkArea; - m_props[tColorMap]->GetForm()->Visible = false; + m_props[tColorMap] = new TAddFloatForm(this, pp_cm_influence); + m_props[tColorMap]->GetForm()->Parent = WorkArea; + m_props[tColorMap]->GetForm()->Visible = false; - m_Marker = 0.0f; + m_Marker = 0.0f; - TabControl->TabIndex = 0; - TabControlChange (TabControl); + TabControl->TabIndex = 0; + TabControlChange(TabControl); } + //--------------------------------------------------------------------------- void __fastcall TMainForm::FormDestroy(TObject *Sender) { @@ -63,6 +64,7 @@ void __fastcall TMainForm::FormDestroy(TObject *Sender) m_Animator = NULL; delete frmConstructor; } + //--------------------------------------------------------------------------- void __fastcall TMainForm::FormResize(TObject *Sender) { @@ -70,57 +72,62 @@ void __fastcall TMainForm::FormResize(TObject *Sender) Image->Picture->Bitmap->Height = 0; Image->Picture->Bitmap->Width = Image->Width; Image->Picture->Bitmap->Height = Image->Height; - UpdateGraph (); + UpdateGraph(); } + //--------------------------------------------------------------------------- void __fastcall TMainForm::NewEffectButtonClick(TObject *Sender) { - if (Application->MessageBox ("Do you wish to create a new effect ?", "Warning", MB_YESNO | MB_ICONSTOP) == IDNO) - return; - - m_Animator->Create (); - UpdateGraph (); - - m_props[tAddColor]->Clear(); - m_props[tBaseColor]->Clear(); - m_props[tGray]->Clear(); - m_props[tDuality]->Clear(); - m_props[tNoise]->Clear(); - m_props[tBlur]->Clear(); + if (Application->MessageBox("Do you wish to create a new effect ?", "Warning", MB_YESNO|MB_ICONSTOP)==IDNO) + return; + + m_Animator->Create(); + UpdateGraph(); + + m_props[tAddColor]->Clear(); + m_props[tBaseColor]->Clear(); + m_props[tGray]->Clear(); + m_props[tDuality]->Clear(); + m_props[tNoise]->Clear(); + m_props[tBlur]->Clear(); } + //--------------------------------------------------------------------------- void __fastcall TMainForm::FormPaint(TObject *Sender) { - UpdateGraph (); + UpdateGraph(); } + //--------------------------------------------------------------------------- void __fastcall TMainForm::ImageMouseUp(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { -// m_pEffect->add_point (X, Y); + // m_pEffect->add_point (X, Y); } + //--------------------------------------------------------------------------- void __fastcall TMainForm::GrayColorClick(TObject *Sender) { -// m_pEffect->get_add_color()->show_constructor (); + // m_pEffect->get_add_color()->show_constructor (); } + //--------------------------------------------------------------------------- void TMainForm::PointListSetTime(int idx, float time) { string256 str; - sprintf(str,"%2.2f",time); + sprintf(str, "%2.2f", time); PointList->Items->Strings[idx] = str; } void TMainForm::FillPointList() { PointList->Clear(); - CPostProcessParam* cparam = MainForm->m_Animator->GetParam (m_ActiveShowForm->GetTimeChannel()); + CPostProcessParam *cparam = MainForm->m_Animator->GetParam(m_ActiveShowForm->GetTimeChannel()); u32 cnt = cparam->get_keys_count(); - for(u32 i=0; iAddItem("", NULL); - float t = cparam->get_key_time(i); + float t = cparam->get_key_time(i); PointListSetTime(PointList->Count-1, t); } } @@ -128,149 +135,154 @@ void TMainForm::FillPointList() void __fastcall TMainForm::TabControlChange(TObject *Sender) { if (m_ActiveShowForm) - { - m_ActiveShowForm->GetForm()->Visible = false; - m_ActiveShowForm = NULL; - } + { + m_ActiveShowForm->GetForm()->Visible = false; + m_ActiveShowForm = NULL; + } m_ActiveShowForm = m_props[TabControl->TabIndex]; - - m_ActiveShowForm->GetForm()->Parent = WorkArea; - m_ActiveShowForm->GetForm()->Left = 0; - m_ActiveShowForm->GetForm()->Top = 0; - m_ActiveShowForm->GetForm()->Width = WorkArea->Width; - m_ActiveShowForm->GetForm()->Height = WorkArea->Height; - m_ActiveShowForm->GetForm()->Visible = true; - - FillPointList (); - - if(PointList->Count) - PointList->ItemIndex = 0; - - PointListClick (NULL); - UpdateGraph (); + + m_ActiveShowForm->GetForm()->Parent = WorkArea; + m_ActiveShowForm->GetForm()->Left = 0; + m_ActiveShowForm->GetForm()->Top = 0; + m_ActiveShowForm->GetForm()->Width = WorkArea->Width; + m_ActiveShowForm->GetForm()->Height = WorkArea->Height; + m_ActiveShowForm->GetForm()->Visible = true; + + FillPointList(); + + if (PointList->Count) + PointList->ItemIndex = 0; + + PointListClick(NULL); + UpdateGraph(); } + //--------------------------------------------------------------------------- -void TMainForm::SetMarkerPosition (float time) +void TMainForm::SetMarkerPosition(float time) { m_Marker = time; - UpdateGraph (); + UpdateGraph(); } + //--------------------------------------------------------------------------- void __fastcall TMainForm::LoadButtonClick(TObject *Sender) { -/* - if (m_Animator->GetLength() != 0.0f) - if (Application->MessageBox ("Do you wish to save current effect ?", "Warning", MB_YESNO | MB_ICONSTOP) == IDYES) - SaveButtonClick (Sender); -*/ - if(OpenDialog->Execute ()) + /* + if (m_Animator->GetLength() != 0.0f) + if (Application->MessageBox ("Do you wish to save current effect ?", "Warning", MB_YESNO | MB_ICONSTOP) == IDYES) + SaveButtonClick (Sender); + */ + if (OpenDialog->Execute()) { m_Marker = 0.0f; - m_Animator->Load (OpenDialog->FileName.c_str ()); - Caption = OpenDialog->FileName.c_str (); + m_Animator->Load(OpenDialog->FileName.c_str()); + Caption = OpenDialog->FileName.c_str(); - TabControl->TabIndex = 0; - TabControlChange (TabControl); + TabControl->TabIndex = 0; + TabControlChange(TabControl); } } void __fastcall TMainForm::SaveButtonClick(TObject *Sender) { - if (m_Animator->GetLength() == 0.0f) return; + if (m_Animator->GetLength()==0.0f) + return; if (SaveDialog->Execute()) { - m_Animator->Save (SaveDialog->FileName.c_str ()); - Caption = SaveDialog->FileName.c_str (); + m_Animator->Save(SaveDialog->FileName.c_str()); + Caption = SaveDialog->FileName.c_str(); } } void TMainForm::UpdateGraph() { - if(!m_Animator) return; - TCanvas *canvas = Image->Picture->Bitmap->Canvas; - canvas->Brush->Color = clWhite; - canvas->FillRect (TRect (0, 0, Image->Picture->Bitmap->Width, Image->Picture->Bitmap->Height)); - canvas->Pen->Color = clBlack; - canvas->MoveTo (0, Image->Picture->Bitmap->Height / 2); - canvas->LineTo (Image->Picture->Bitmap->Width, Image->Picture->Bitmap->Height / 2); - canvas->MoveTo (0, 0); - canvas->LineTo (Image->Picture->Bitmap->Width, 0); - canvas->MoveTo (0, Image->Picture->Bitmap->Height - 1); - canvas->LineTo (Image->Picture->Bitmap->Width, Image->Picture->Bitmap->Height - 1); - canvas->TextOutA (0, Image->Picture->Bitmap->Height / 2 - 14, "0.0"); - canvas->TextOutA (0, Image->Picture->Bitmap->Height - 14, "-1.0"); - canvas->TextOutA (0, 2, "1.0"); - - - float alltime = m_Animator->GetLength (); - string128 buf; - sprintf (buf, "Effect time : %.3f", alltime); + if (!m_Animator) + return; + TCanvas *canvas = Image->Picture->Bitmap->Canvas; + canvas->Brush->Color = clWhite; + canvas->FillRect(TRect(0, 0, Image->Picture->Bitmap->Width, Image->Picture->Bitmap->Height)); + canvas->Pen->Color = clBlack; + canvas->MoveTo(0, Image->Picture->Bitmap->Height/2); + canvas->LineTo(Image->Picture->Bitmap->Width, Image->Picture->Bitmap->Height/2); + canvas->MoveTo(0, 0); + canvas->LineTo(Image->Picture->Bitmap->Width, 0); + canvas->MoveTo(0, Image->Picture->Bitmap->Height-1); + canvas->LineTo(Image->Picture->Bitmap->Width, Image->Picture->Bitmap->Height-1); + canvas->TextOutA(0, Image->Picture->Bitmap->Height/2-14, "0.0"); + canvas->TextOutA(0, Image->Picture->Bitmap->Height-14, "-1.0"); + canvas->TextOutA(0, 2, "1.0"); + + + float alltime = m_Animator->GetLength(); + string128 buf; + sprintf(buf, "Effect time : %.3f", alltime); StatusBar->Panels->Items[0]->Text = buf; - if (alltime == 0.0f) return; - - float width = (float)Image->Picture->Bitmap->Width, height = (float)Image->Picture->Bitmap->Height * 0.5f; + if (alltime==0.0f) + return; + + float width = (float)Image->Picture->Bitmap->Width, height = (float)Image->Picture->Bitmap->Height*0.5f; //draw marker - int left = (int)(width / alltime * m_Marker); - canvas->MoveTo (left, 0); - canvas->Pen->Style = psDot; - canvas->LineTo (left, Image->Picture->Bitmap->Height); - canvas->Pen->Style = psSolid; + int left = (int)(width/alltime*m_Marker); + canvas->MoveTo(left, 0); + canvas->Pen->Style = psDot; + canvas->LineTo(left, Image->Picture->Bitmap->Height); + canvas->Pen->Style = psSolid; - SPPInfo m_EffectorParams; - ZeroMemory (&m_EffectorParams, sizeof (SPPInfo)); + SPPInfo m_EffectorParams; + ZeroMemory(&m_EffectorParams, sizeof (SPPInfo)); - float increment = alltime / (float)Image->Width; + float increment = alltime/(float)Image->Width; - for (float t = 0.0f; t < alltime; t += increment) + for (float t = 0.0f; tProcess (t, m_EffectorParams); - int x = (int)(width / alltime * t); - - for(u32 idx =pp_base_color;idxProcess(t, m_EffectorParams); + int x = (int)(width/alltime*t); + + for (u32 idx = pp_base_color; idxDrawChannel((_pp_params)idx)) + if (!m_ActiveShowForm->DrawChannel((_pp_params)idx)) continue; - + switch (idx) - { - case pp_base_color: - canvas->Pixels[x][(int)(-m_EffectorParams.color_base.r * height + height)] = clRed; - canvas->Pixels[x][(int)(-m_EffectorParams.color_base.g * height + height)] = clGreen; - canvas->Pixels[x][(int)(-m_EffectorParams.color_base.b * height + height)] = clBlue; - break; - case pp_add_color: - canvas->Pixels[x][(int)(-m_EffectorParams.color_add.r * height + height)] = clRed; - canvas->Pixels[x][(int)(-m_EffectorParams.color_add.g * height + height)] = clGreen; - canvas->Pixels[x][(int)(-m_EffectorParams.color_add.b * height + height)] = clBlue; - break; - case pp_gray_color: - canvas->Pixels[x][(int)(-m_EffectorParams.color_gray.r * height + height)] = clRed; - canvas->Pixels[x][(int)(-m_EffectorParams.color_gray.g * height + height)] = clGreen; - canvas->Pixels[x][(int)(-m_EffectorParams.color_gray.b * height + height)] = clBlue; - break; - case pp_gray_value: - canvas->Pixels[x][(int)(-m_EffectorParams.blur * height + height)] = clBlack; - break; - case pp_blur: - canvas->Pixels[x][(int)(-m_EffectorParams.gray * height + height)] = clBlack; - break; - case pp_dual_h: - canvas->Pixels[x][(int)(-m_EffectorParams.duality.h * height + height)] = clRed; - break; - case pp_dual_v: - canvas->Pixels[x][(int)(-m_EffectorParams.duality.v * height + height)] = clGreen; - break; - case pp_noise_i: - canvas->Pixels[x][(int)(-m_EffectorParams.noise.intensity * height + height)] = clRed; - break; - case pp_noise_g: - canvas->Pixels[x][(int)(-m_EffectorParams.noise.grain * height + height)] = clGreen; - break; - case pp_noise_f: - canvas->Pixels[x][(int)(-m_EffectorParams.noise.fps * height + height)] = clBlue; - break; - }//switch - }//channel + { + case pp_base_color: + canvas->Pixels[x][(int)(-m_EffectorParams.color_base.r*height+height)] = clRed; + canvas->Pixels[x][(int)(-m_EffectorParams.color_base.g*height+height)] = clGreen; + canvas->Pixels[x][(int)(-m_EffectorParams.color_base.b*height+height)] = clBlue; + break; + case pp_add_color: + canvas->Pixels[x][(int)(-m_EffectorParams.color_add.r*height+height)] = clRed; + canvas->Pixels[x][(int)(-m_EffectorParams.color_add.g*height+height)] = clGreen; + canvas->Pixels[x][(int)(-m_EffectorParams.color_add.b*height+height)] = clBlue; + break; + case pp_gray_color: + canvas->Pixels[x][(int)(-m_EffectorParams.color_gray.r*height+height)] = clRed; + canvas->Pixels[x][(int)(-m_EffectorParams.color_gray.g*height+height)] = clGreen; + canvas->Pixels[x][(int)(-m_EffectorParams.color_gray.b*height+height)] = clBlue; + break; + case pp_gray_value: + canvas->Pixels[x][(int)(-m_EffectorParams.blur*height+height)] = clBlack; + break; + case pp_blur: + canvas->Pixels[x][(int)(-m_EffectorParams.gray*height+height)] = clBlack; + break; + case pp_dual_h: + canvas->Pixels[x][(int)(-m_EffectorParams.duality.h*height+height)] = clRed; + break; + case pp_dual_v: + canvas->Pixels[x][(int)(-m_EffectorParams.duality.v*height+height)] = clGreen; + break; + case pp_noise_i: + canvas->Pixels[x][(int)(-m_EffectorParams.noise.intensity*height+height)] = clRed; + break; + case pp_noise_g: + canvas->Pixels[x][(int)(-m_EffectorParams.noise.grain*height+height)] = clGreen; + break; + case pp_noise_f: + canvas->Pixels[x][(int)(-m_EffectorParams.noise.fps*height+height)] = clBlue; + break; + }//switch + }//channel }//time } @@ -278,89 +290,93 @@ void TMainForm::UpdateGraph() void __fastcall TMainForm::PointListClick(TObject *Sender) { - m_ActiveShowForm->Lock(true); - m_ActiveShowForm->ShowCurrent(PointList->ItemIndex); - m_ActiveShowForm->Lock(false); + m_ActiveShowForm->Lock(true); + m_ActiveShowForm->ShowCurrent(PointList->ItemIndex); + m_ActiveShowForm->Lock(false); } + //--------------------------------------------------------------------------- void __fastcall TMainForm::btnAddKeyClick(TObject *Sender) { - int idx = PointList->ItemIndex; - m_ActiveShowForm->Lock (true); - m_ActiveShowForm->AddNew (PointList->ItemIndex); - m_ActiveShowForm->Lock (false); - - TabControlChange (TabControl); - PointList->ItemIndex = idx+1; - PointListClick (NULL); + int idx = PointList->ItemIndex; + m_ActiveShowForm->Lock(true); + m_ActiveShowForm->AddNew(PointList->ItemIndex); + m_ActiveShowForm->Lock(false); + + TabControlChange(TabControl); + PointList->ItemIndex = idx+1; + PointListClick(NULL); } + //--------------------------------------------------------------------------- void __fastcall TMainForm::btnRemoveKeyClick(TObject *Sender) { - int idx = PointList->ItemIndex; - m_ActiveShowForm->Lock (true); - m_ActiveShowForm->Remove (PointList->ItemIndex); - m_ActiveShowForm->Lock (false); - - TabControlChange (TabControl); - if(PointList->Count>idx) - PointList->ItemIndex = idx; + int idx = PointList->ItemIndex; + m_ActiveShowForm->Lock(true); + m_ActiveShowForm->Remove(PointList->ItemIndex); + m_ActiveShowForm->Lock(false); + + TabControlChange(TabControl); + if (PointList->Count>idx) + PointList->ItemIndex = idx; else - PointList->ItemIndex = idx-1; + PointList->ItemIndex = idx-1; } + //--------------------------------------------------------------------------- void __fastcall TMainForm::ClearAllClick(TObject *Sender) { - m_ActiveShowForm->Lock (true); - m_ActiveShowForm->RemoveAllKeys (); - m_ActiveShowForm->Lock (false); + m_ActiveShowForm->Lock(true); + m_ActiveShowForm->RemoveAllKeys(); + m_ActiveShowForm->Lock(false); - TabControlChange (TabControl); + TabControlChange(TabControl); } + //--------------------------------------------------------------------------- void __fastcall TMainForm::copyFromClick(TObject *Sender) { - TPoint P; - P = Mouse->CursorPos; - PopupCopyFrom->Popup(P.x, P.y); + TPoint P; + P = Mouse->CursorPos; + PopupCopyFrom->Popup(P.x, P.y); } + //--------------------------------------------------------------------------- void __fastcall TMainForm::PopupCopyFromChange(TObject *Sender, - TMenuItem *Source, bool Rebuild) + TMenuItem *Source, bool Rebuild) { -// + // } + //--------------------------------------------------------------------------- void __fastcall TMainForm::PopupClick(TObject *Sender) { - // - TMenuItem* itm = dynamic_cast(Sender); + // + TMenuItem *itm = dynamic_cast(Sender); - m_ActiveShowForm->Lock (true); - m_ActiveShowForm->RemoveAllKeys (); + m_ActiveShowForm->Lock(true); + m_ActiveShowForm->RemoveAllKeys(); - CPostProcessParam* cparam = MainForm->m_Animator->GetParam (m_props[itm->Tag]->GetTimeChannel()); - u32 cnt = cparam->get_keys_count(); + CPostProcessParam *cparam = MainForm->m_Animator->GetParam(m_props[itm->Tag]->GetTimeChannel()); + u32 cnt = cparam->get_keys_count(); string256 str; - for(u32 i=0; iget_key_time(i); - m_ActiveShowForm->CreateKey (t); + float t = cparam->get_key_time(i); + m_ActiveShowForm->CreateKey(t); } - m_ActiveShowForm->Lock (false); + m_ActiveShowForm->Lock(false); - TabControlChange (NULL); + TabControlChange(NULL); } -//--------------------------------------------------------------------------- - - +//--------------------------------------------------------------------------- diff --git a/src/editors/PPEditor/main.h b/src/editors/PPEditor/main.h index ded346952e8..f0bb597b4ff 100644 --- a/src/editors/PPEditor/main.h +++ b/src/editors/PPEditor/main.h @@ -25,8 +25,8 @@ class TPPPropEditor; class TMainForm : public TForm { -__published: - TPanel *Panel; + __published: + TPanel*Panel; TToolBar *ToolBar1; TStatusBar *StatusBar; TImage *Image; @@ -38,58 +38,60 @@ class TMainForm : public TForm TSaveDialog *SaveDialog; TOpenDialog *OpenDialog; TImageList *ImageList; - TListBox *PointList; - TMxLabel *RxLabel1; - TPanel *WorkArea; - TButton *btnAddKey; - TButton *btnRemoveKey; - TButton *ClearAll; - TButton *copyFrom; - TPopupMenu *PopupCopyFrom; - TMenuItem *Addcolor1; - TMenuItem *BaseColor1; - TMenuItem *Graycolor1; - TMenuItem *Duality1; - TMenuItem *Noise1; - TMenuItem *Blur1; - TMainMenu *MainMenu1; - TMenuItem *File1; - TMenuItem *Save1; - TMenuItem *Load1; - TMenuItem *New1; - TMenuItem *N1; + TListBox *PointList; + TMxLabel *RxLabel1; + TPanel *WorkArea; + TButton *btnAddKey; + TButton *btnRemoveKey; + TButton *ClearAll; + TButton *copyFrom; + TPopupMenu *PopupCopyFrom; + TMenuItem *Addcolor1; + TMenuItem *BaseColor1; + TMenuItem *Graycolor1; + TMenuItem *Duality1; + TMenuItem *Noise1; + TMenuItem *Blur1; + TMainMenu *MainMenu1; + TMenuItem *File1; + TMenuItem *Save1; + TMenuItem *Load1; + TMenuItem *New1; + TMenuItem *N1; void __fastcall FormResize(TObject *Sender); void __fastcall NewEffectButtonClick(TObject *Sender); void __fastcall FormDestroy(TObject *Sender); void __fastcall FormPaint(TObject *Sender); void __fastcall ImageMouseUp(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); + TShiftState Shift, int X, int Y); void __fastcall GrayColorClick(TObject *Sender); void __fastcall TabControlChange(TObject *Sender); void __fastcall LoadButtonClick(TObject *Sender); void __fastcall SaveButtonClick(TObject *Sender); - void __fastcall PointListClick(TObject *Sender); - void __fastcall btnAddKeyClick(TObject *Sender); - void __fastcall btnRemoveKeyClick(TObject *Sender); - void __fastcall ClearAllClick(TObject *Sender); - void __fastcall copyFromClick(TObject *Sender); - void __fastcall PopupCopyFromChange(TObject *Sender, TMenuItem *Source, - bool Rebuild); - void __fastcall PopupClick(TObject *Sender); -private: // User declarations - TPPPropEditor* m_props[6]; - SPPInfo m_Params; - TPPPropEditor* m_ActiveShowForm; - float m_Marker; -public: // User declarations - __fastcall TMainForm (TComponent* Owner); - void SetMarkerPosition (float time); - void UpdateGraph (); - void FillPointList (); - void PointListSetTime (int idx, float time); - CPostprocessAnimator* m_Animator; + void __fastcall PointListClick(TObject *Sender); + void __fastcall btnAddKeyClick(TObject *Sender); + void __fastcall btnRemoveKeyClick(TObject *Sender); + void __fastcall ClearAllClick(TObject *Sender); + void __fastcall copyFromClick(TObject *Sender); + void __fastcall PopupCopyFromChange(TObject *Sender, TMenuItem *Source, + bool Rebuild); + void __fastcall PopupClick(TObject *Sender); +private: // User declarations + TPPPropEditor *m_props[6]; + SPPInfo m_Params; + TPPPropEditor *m_ActiveShowForm; + float m_Marker; +public: // User declarations + __fastcall TMainForm(TComponent *Owner); + void SetMarkerPosition(float time); + void UpdateGraph(); + void FillPointList(); + void PointListSetTime(int idx, float time); + CPostprocessAnimator *m_Animator; }; + //--------------------------------------------------------------------------- -extern PACKAGE TMainForm *MainForm; +extern PACKAGE TMainForm * MainForm; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/PPEditor/newdialog.cpp b/src/editors/PPEditor/newdialog.cpp index 5d2dd84e066..263687ad950 100644 --- a/src/editors/PPEditor/newdialog.cpp +++ b/src/editors/PPEditor/newdialog.cpp @@ -8,17 +8,20 @@ #pragma package(smart_init) #pragma resource "*.dfm" TNewEffectDialog *NewEffectDialog; + //--------------------------------------------------------------------------- -__fastcall TNewEffectDialog::TNewEffectDialog(TComponent* Owner) - : TForm(Owner) -{ -} +__fastcall TNewEffectDialog::TNewEffectDialog(TComponent *Owner) + : TForm(Owner) {} + //--------------------------------------------------------------------------- void __fastcall TNewEffectDialog::TimeChange(TObject *Sender) { - if (Time->Value > 0.0f) - Button1->Enabled = true; + if (Time->Value>0.0f) + Button1->Enabled = true; else - Button1->Enabled = false; + Button1->Enabled = false; } + //--------------------------------------------------------------------------- + + diff --git a/src/editors/PPEditor/newdialog.h b/src/editors/PPEditor/newdialog.h index 08ac1ffeb50..2b1c9e2d0c6 100644 --- a/src/editors/PPEditor/newdialog.h +++ b/src/editors/PPEditor/newdialog.h @@ -8,20 +8,23 @@ #include #include #include + //--------------------------------------------------------------------------- class TNewEffectDialog : public TForm { -__published: // IDE-managed Components - TMultiObjSpinEdit *Time; + __published: // IDE-managed Components + TMultiObjSpinEdit*Time; TMxLabel *RxLabel1; TButton *Button1; TButton *Button2; void __fastcall TimeChange(TObject *Sender); -private: // User declarations -public: // User declarations - __fastcall TNewEffectDialog(TComponent* Owner); +private: // User declarations +public: // User declarations + __fastcall TNewEffectDialog(TComponent *Owner); }; + //--------------------------------------------------------------------------- -extern PACKAGE TNewEffectDialog *NewEffectDialog; +extern PACKAGE TNewEffectDialog * NewEffectDialog; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/PPEditor/single_param.cpp b/src/editors/PPEditor/single_param.cpp index e2681297111..bfabeeb6e7d 100644 --- a/src/editors/PPEditor/single_param.cpp +++ b/src/editors/PPEditor/single_param.cpp @@ -10,37 +10,37 @@ #pragma link "multi_edit" #pragma link "MXCtrls" #pragma resource "*.dfm" -__fastcall TAddFloatForm::TAddFloatForm(TComponent* Owner, pp_params p) - : TForm(Owner),m_pp_params(p) +__fastcall TAddFloatForm::TAddFloatForm(TComponent *Owner, pp_params p) + : TForm(Owner), m_pp_params(p) { Value1->MinValue = -1; Value1->MaxValue = 1; Value1->Decimal = 2; Value2->Decimal = 2; - Value1->Increment = 0.01f; - Value2->Increment = 0.01f; + Value1->Increment = 0.01f; + Value2->Increment = 0.01f; cmTextureName->Visible = false; - if(m_pp_params==pp_dual_h) + if (m_pp_params==pp_dual_h) { - Label1->Caption = "Duality-H"; - Label2->Caption = "Duality-V"; + Label1->Caption = "Duality-H"; + Label2->Caption = "Duality-V"; Label2->Visible = true; Value2->Visible = true; Value1->MinValue = -1.0f; Value1->MaxValue = 1.0f; Value1->Decimal = 3; - Value1->Increment = 0.001f; + Value1->Increment = 0.001f; Value2->MinValue = -1.0f; Value2->MaxValue = 1.0f; Value2->Decimal = 3; - Value2->Increment = 0.001f; - }else - if(m_pp_params==pp_noise_i) + Value2->Increment = 0.001f; + } + else if (m_pp_params==pp_noise_i) { - Label1->Caption = "Noise Intensity"; - Label2->Caption = "Noise Grain"; - Label3->Caption = "Noise FPS"; + Label1->Caption = "Noise Intensity"; + Label2->Caption = "Noise Grain"; + Label3->Caption = "Noise FPS"; Label2->Visible = true; Value2->Visible = true; @@ -53,10 +53,10 @@ __fastcall TAddFloatForm::TAddFloatForm(TComponent* Owner, pp_params p) Value2->MaxValue = 1000.0f; Value3->MinValue = 1.0f;; Value3->MaxValue = 1000.0f;; - }else - if(m_pp_params==pp_cm_influence) + } + else if (m_pp_params==pp_cm_influence) { - Label1->Caption = "Influence"; + Label1->Caption = "Influence"; Label2->Visible = false; Value2->Visible = false; @@ -68,229 +68,238 @@ __fastcall TAddFloatForm::TAddFloatForm(TComponent* Owner, pp_params p) cmTextureName->Visible = true; }; } + //--------------------------------------------------------------------------- -void TAddFloatForm::Clear() +void TAddFloatForm::Clear() { - Lock(true); - TimeValue->Value = 0.0f; - Value1->Value = 0.0f; - Value2->Value = 0.0f; - Value3->Value = 0.0f; + Lock(true); + TimeValue->Value = 0.0f; + Value1->Value = 0.0f; + Value2->Value = 0.0f; + Value3->Value = 0.0f; cmTextureName->Text = ""; - Lock(false); + Lock(false); } void TAddFloatForm::ShowCurrent(u32 keyIdx) { - if(keyIdx==-1) + if (keyIdx==-1) { - Clear(); + Clear(); return; } - CPostProcessParam* cparam = MainForm->m_Animator->GetParam (GetTimeChannel()); - float time = cparam->get_key_time(keyIdx); - MainForm->SetMarkerPosition (time); + CPostProcessParam *cparam = MainForm->m_Animator->GetParam(GetTimeChannel()); + float time = cparam->get_key_time(keyIdx); + MainForm->SetMarkerPosition(time); - if(keyIdx>0) - TimeValue->MinValue = cparam->get_key_time(keyIdx-1)+0.02f; - else - TimeValue->MinValue = 0.0f; + if (keyIdx>0) + TimeValue->MinValue = cparam->get_key_time(keyIdx-1)+0.02f; + else + TimeValue->MinValue = 0.0f; - if(cparam->get_keys_count()>keyIdx+1) - TimeValue->MaxValue = cparam->get_key_time(keyIdx+1)-0.02f; - else - TimeValue->MaxValue = 1000.0f; - - TimeValue->Value = time; + if (cparam->get_keys_count()>keyIdx+1) + TimeValue->MaxValue = cparam->get_key_time(keyIdx+1)-0.02f; + else + TimeValue->MaxValue = 1000.0f; - float val; - cparam->get_value (time, val, 0); - Value1->Value = val; + TimeValue->Value = time; - if(m_pp_params==pp_dual_h) + float val; + cparam->get_value(time, val, 0); + Value1->Value = val; + + if (m_pp_params==pp_dual_h) { - cparam = MainForm->m_Animator->GetParam (pp_dual_v); + cparam = MainForm->m_Animator->GetParam(pp_dual_v); - cparam->get_value (time, val, 0); - Value2->Value = val; - }else - if(m_pp_params==pp_noise_i) + cparam->get_value(time, val, 0); + Value2->Value = val; + } + else if (m_pp_params==pp_noise_i) { - cparam = MainForm->m_Animator->GetParam (pp_noise_g); + cparam = MainForm->m_Animator->GetParam(pp_noise_g); - cparam->get_value (time, val, 0); - Value2->Value = val; + cparam->get_value(time, val, 0); + Value2->Value = val; - cparam = MainForm->m_Animator->GetParam (pp_noise_f); + cparam = MainForm->m_Animator->GetParam(pp_noise_f); - cparam->get_value (time, val, 0); - Value3->Value = val; - }else - if(m_pp_params==pp_cm_influence) + cparam->get_value(time, val, 0); + Value3->Value = val; + } + else if (m_pp_params==pp_cm_influence) { - cmTextureName->Text = MainForm->m_Animator->PPinfo().cm_tex1.c_str(); + cmTextureName->Text = MainForm->m_Animator->PPinfo().cm_tex1.c_str(); } } bool TAddFloatForm::DrawChannel(_pp_params p) { - switch(m_pp_params) + switch (m_pp_params) { - case pp_dual_h: return (p==pp_dual_h)||(p==pp_dual_v); - case pp_noise_i: return (p==pp_noise_i)||(p==pp_noise_g)||(p==pp_noise_f); - case pp_cm_influence: return (p==pp_cm_influence); - default:R_ASSERT(0); + case pp_dual_h: return (p==pp_dual_h)||(p==pp_dual_v); + case pp_noise_i: return (p==pp_noise_i)||(p==pp_noise_g)||(p==pp_noise_f); + case pp_cm_influence: return (p==pp_cm_influence); + default: R_ASSERT(0); } return false; } void __fastcall TAddFloatForm::TimeValueExit(TObject *Sender) { - if (m_bLocked) return; - if (MainForm->PointList->ItemIndex == -1) return; - TMultiObjSpinEdit* spin = dynamic_cast(Sender); - if(spin->Color == clLime) + if (m_bLocked) + return; + if (MainForm->PointList->ItemIndex==-1) + return; + TMultiObjSpinEdit *spin = dynamic_cast(Sender); + if (spin->Color==clLime) { - if(TimeValue->ValueMinValue) - TimeValue->Value=TimeValue->MinValue; - if(TimeValue->Value>TimeValue->MaxValue) - TimeValue->Value=TimeValue->MaxValue; + if (TimeValue->ValueMinValue) + TimeValue->Value = TimeValue->MinValue; + if (TimeValue->Value>TimeValue->MaxValue) + TimeValue->Value = TimeValue->MaxValue; + + CPostProcessParam *cparam = MainForm->m_Animator->GetParam(GetTimeChannel()); + + float time_prev = cparam->get_key_time(MainForm->PointList->ItemIndex); + cparam->delete_value(time_prev); - CPostProcessParam* cparam = MainForm->m_Animator->GetParam (GetTimeChannel()); + float time = TimeValue->Value; + cparam->add_value(time, Value1->Value, 0); - float time_prev = cparam->get_key_time(MainForm->PointList->ItemIndex); - cparam->delete_value (time_prev); - - float time = TimeValue->Value; - cparam->add_value (time, Value1->Value, 0); - - if(m_pp_params==pp_dual_h) + if (m_pp_params==pp_dual_h) { - cparam = MainForm->m_Animator->GetParam (pp_dual_v); - cparam->delete_value (time_prev); - cparam->add_value (time, Value2->Value, 0); - }else - if(m_pp_params==pp_noise_i) + cparam = MainForm->m_Animator->GetParam(pp_dual_v); + cparam->delete_value(time_prev); + cparam->add_value(time, Value2->Value, 0); + } + else if (m_pp_params==pp_noise_i) { - cparam = MainForm->m_Animator->GetParam (pp_noise_g); - cparam->delete_value (time_prev); - cparam->add_value (time, Value2->Value, 0); + cparam = MainForm->m_Animator->GetParam(pp_noise_g); + cparam->delete_value(time_prev); + cparam->add_value(time, Value2->Value, 0); - cparam = MainForm->m_Animator->GetParam (pp_noise_f); - cparam->delete_value (time_prev); - cparam->add_value (time, Value3->Value, 0); + cparam = MainForm->m_Animator->GetParam(pp_noise_f); + cparam->delete_value(time_prev); + cparam->add_value(time, Value3->Value, 0); } - MainForm->PointListSetTime (MainForm->PointList->ItemIndex, time); + MainForm->PointListSetTime(MainForm->PointList->ItemIndex, time); MainForm->UpdateGraph(); - spin->Color = clWindow; + spin->Color = clWindow; } } void __fastcall TAddFloatForm::ChangeParam(TObject *Sender) { - if (m_bLocked) return; - if (MainForm->PointList->ItemIndex == -1) return; - TMultiObjSpinEdit* spin = dynamic_cast(Sender); + if (m_bLocked) + return; + if (MainForm->PointList->ItemIndex==-1) + return; + TMultiObjSpinEdit *spin = dynamic_cast(Sender); spin->Color = clLime; } void TAddFloatForm::AddNew(u32 keyIdx) { - CPostProcessParam* cparam = MainForm->m_Animator->GetParam (GetTimeChannel()); - - float time = (keyIdx!=-1)?cparam->get_key_time(keyIdx):0.0f; - MainForm->SetMarkerPosition (time); - time += 0.01f; - CreateKey (time); + CPostProcessParam *cparam = MainForm->m_Animator->GetParam(GetTimeChannel()); + float time = (keyIdx!=-1) ? cparam->get_key_time(keyIdx) : 0.0f; + MainForm->SetMarkerPosition(time); + time += 0.01f; + CreateKey(time); } void TAddFloatForm::Remove(u32 keyIdx) { - if(keyIdx==-1) return; - - CPostProcessParam* cparam = MainForm->m_Animator->GetParam (GetTimeChannel()); - - float time = cparam->get_key_time(keyIdx); - - cparam->delete_value (time); - - if(m_pp_params==pp_dual_h) - { - cparam = MainForm->m_Animator->GetParam (pp_dual_v); - cparam->delete_value (time); - }else - if(m_pp_params==pp_noise_i) - { - cparam = MainForm->m_Animator->GetParam (pp_noise_g); - cparam->delete_value (time); - cparam = MainForm->m_Animator->GetParam (pp_noise_f); - cparam->delete_value (time); - }; + if (keyIdx==-1) + return; + + CPostProcessParam *cparam = MainForm->m_Animator->GetParam(GetTimeChannel()); + + float time = cparam->get_key_time(keyIdx); + + cparam->delete_value(time); + + if (m_pp_params==pp_dual_h) + { + cparam = MainForm->m_Animator->GetParam(pp_dual_v); + cparam->delete_value(time); + } + else if (m_pp_params==pp_noise_i) + { + cparam = MainForm->m_Animator->GetParam(pp_noise_g); + cparam->delete_value(time); + cparam = MainForm->m_Animator->GetParam(pp_noise_f); + cparam->delete_value(time); + }; } -void TAddFloatForm::RemoveAllKeys() +void TAddFloatForm::RemoveAllKeys() { - CPostProcessParam* cparam = MainForm->m_Animator->GetParam (GetTimeChannel()); - cparam->clear_all_keys (); - - if(m_pp_params==pp_dual_h) - { - cparam = MainForm->m_Animator->GetParam (pp_dual_h); - cparam->clear_all_keys (); - }else - if(m_pp_params==pp_noise_i) - { - cparam = MainForm->m_Animator->GetParam (pp_noise_g); - cparam->clear_all_keys (); - - cparam = MainForm->m_Animator->GetParam (pp_noise_f); - cparam->clear_all_keys (); - } + CPostProcessParam *cparam = MainForm->m_Animator->GetParam(GetTimeChannel()); + cparam->clear_all_keys(); + + if (m_pp_params==pp_dual_h) + { + cparam = MainForm->m_Animator->GetParam(pp_dual_h); + cparam->clear_all_keys(); + } + else if (m_pp_params==pp_noise_i) + { + cparam = MainForm->m_Animator->GetParam(pp_noise_g); + cparam->clear_all_keys(); + + cparam = MainForm->m_Animator->GetParam(pp_noise_f); + cparam->clear_all_keys(); + } } -void TAddFloatForm::CreateKey(float time) +void TAddFloatForm::CreateKey(float time) { - CPostProcessParam* cparam = MainForm->m_Animator->GetParam (GetTimeChannel()); - - cparam->add_value (time, 0.0f, 0); - cparam->update_value (time, 0.33f, 0); - - - if(m_pp_params==pp_dual_h) - { - cparam = MainForm->m_Animator->GetParam (pp_dual_v); - cparam->add_value (time, 0.0f, 0); - cparam->update_value (time, 0.44f, 0); - } - if(m_pp_params==pp_noise_i) - { - cparam = MainForm->m_Animator->GetParam (pp_noise_g); - cparam->add_value (time, 0.0f, 0); - cparam->update_value (time, 0.11f, 0); - - cparam = MainForm->m_Animator->GetParam (pp_noise_f); - cparam->add_value (time, 0.0f, 0); - cparam->update_value (time, 0.22f, 0); - } + CPostProcessParam *cparam = MainForm->m_Animator->GetParam(GetTimeChannel()); + + cparam->add_value(time, 0.0f, 0); + cparam->update_value(time, 0.33f, 0); + + + if (m_pp_params==pp_dual_h) + { + cparam = MainForm->m_Animator->GetParam(pp_dual_v); + cparam->add_value(time, 0.0f, 0); + cparam->update_value(time, 0.44f, 0); + } + if (m_pp_params==pp_noise_i) + { + cparam = MainForm->m_Animator->GetParam(pp_noise_g); + cparam->add_value(time, 0.0f, 0); + cparam->update_value(time, 0.11f, 0); + + cparam = MainForm->m_Animator->GetParam(pp_noise_f); + cparam->add_value(time, 0.0f, 0); + cparam->update_value(time, 0.22f, 0); + } } + //--------------------------------------------------------------------------- void __fastcall TAddFloatForm::TimeValueKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift) + TShiftState Shift) { - if(Key==VK_RETURN) - TimeValueExit(Sender); + if (Key==VK_RETURN) + TimeValueExit(Sender); } + //--------------------------------------------------------------------------- void __fastcall TAddFloatForm::cmTextureNameChange(TObject *Sender) { MainForm->m_Animator->PPinfo().cm_tex1 = cmTextureName->Text.c_str(); } + //--------------------------------------------------------------------------- + diff --git a/src/editors/PPEditor/single_param.h b/src/editors/PPEditor/single_param.h index 7db0a636c41..21cd41dbe66 100644 --- a/src/editors/PPEditor/single_param.h +++ b/src/editors/PPEditor/single_param.h @@ -8,42 +8,58 @@ #include #include #include + //--------------------------------------------------------------------------- class TAddFloatForm : public TForm, public TPPPropEditor { -__published: // IDE-managed Components - TGroupBox *GroupBox1; - TMxLabel *Label1; - TMultiObjSpinEdit *Value1; - TMxLabel *Label2; - TMultiObjSpinEdit *Value2; - TMxLabel *MxLabel2; - TMultiObjSpinEdit *Value3; - TMxLabel *Label3; - TMxLabel *MxLabel1; - TMultiObjSpinEdit *TimeValue; - TEdit *cmTextureName; - void __fastcall ChangeParam(TObject *Sender); - void __fastcall TimeValueExit(TObject *Sender); - void __fastcall TimeValueKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift); - void __fastcall cmTextureNameChange(TObject *Sender); -private: // User declarations - pp_params m_Param; - _pp_params m_pp_params; - bool m_bLocked; -public: // User declarations - virtual void Lock (bool b){m_bLocked=b;} - __fastcall TAddFloatForm (TComponent* Owner, pp_params param); - - virtual void ShowCurrent (u32 keyIdx); - virtual _pp_params GetTimeChannel () {return m_pp_params;}; - virtual bool DrawChannel (_pp_params p);; - virtual void Clear (); - virtual TForm* GetForm () {return this;}; - virtual void AddNew (u32 keyIdx); - virtual void Remove (u32 keyIdx); - virtual void RemoveAllKeys (); - virtual void CreateKey (float t); + __published: // IDE-managed Components + TGroupBox*GroupBox1; + TMxLabel *Label1; + TMultiObjSpinEdit *Value1; + TMxLabel *Label2; + TMultiObjSpinEdit *Value2; + TMxLabel *MxLabel2; + TMultiObjSpinEdit *Value3; + TMxLabel *Label3; + TMxLabel *MxLabel1; + TMultiObjSpinEdit *TimeValue; + TEdit *cmTextureName; + void __fastcall ChangeParam(TObject *Sender); + void __fastcall TimeValueExit(TObject *Sender); + void __fastcall TimeValueKeyDown(TObject *Sender, WORD &Key, + TShiftState Shift); + void __fastcall cmTextureNameChange(TObject *Sender); +private: // User declarations + pp_params m_Param; + _pp_params m_pp_params; + bool m_bLocked; +public: // User declarations + virtual void Lock(bool b) + { + m_bLocked = b; + } + + __fastcall TAddFloatForm(TComponent *Owner, pp_params param); + + virtual void ShowCurrent(u32 keyIdx); + + virtual _pp_params GetTimeChannel() + { + return m_pp_params; + }; + + virtual bool DrawChannel(_pp_params p);; + virtual void Clear(); + + virtual TForm *GetForm() + { + return this; + }; + + virtual void AddNew(u32 keyIdx); + virtual void Remove(u32 keyIdx); + virtual void RemoveAllKeys(); + virtual void CreateKey(float t); }; #endif + diff --git a/src/editors/PPEditor/spline.cpp b/src/editors/PPEditor/spline.cpp index b3e33c30f3d..40d5ae584fd 100644 --- a/src/editors/PPEditor/spline.cpp +++ b/src/editors/PPEditor/spline.cpp @@ -10,125 +10,135 @@ //--------------------------------------------------------------------------- - Spline::Spline () -{ -} +Spline::Spline() {} + //--------------------------------------------------------------------------- - Spline::~Spline () +Spline::~Spline() { m_list.clear(); } + //--------------------------------------------------------------------------- -void Spline::add_point (float value, float deriv, float time) +void Spline::add_point(float value, float deriv, float time) { - for (size_t a = 0; a < m_list.size() - 1; a++) - if (time > m_list[a].time && time < m_list[a + 1].time) - { - point pt = {value, deriv, time}; - m_list.insert (m_list.begin() + a); - get_point (a, pt); - return; - } + for (size_t a = 0; am_list[a].time&&time get_full_time ()) return m_list[m_list.size() - 1].value; - if (time < 0.0f) return ((*(m_list.begin())).value); + if (time>get_full_time()) + return m_list[m_list.size()-1].value; + if (time<0.0f) + return ((*(m_list.begin())).value); size_t index; - for (index = 0; index < m_list.size () - 1; index++) - if (time >= m_list[index].time && time <= m_list[index + 1].time) - break; - - float t = (time - m_list[index].time) / (m_list[index + 1].time - m_list[index].time); - float t2 = t * t; - float t3 = t * t2; - return m_list[index].value * (2 * t3 - 3 * t2 + 1) + - m_list[index].deriv * (t3 - 2 * t2 + 0) + - m_list[index + 1].value * (-2 * t3 + 3 * t2) + - m_list[index + 1].deriv * (t3 - t2); - -// f(t) = p1 * (2*t^3 - 3*t^2 + 1) + -// r1 * (t^3 - 2*t^2 + t) + -// p2 * (-2*t^3 + 3*t^2) + -// r2 * (t^3 - t^2). + for (index = 0; index=m_list[index].time&&time<=m_list[index+1].time) + break; + float t = (time-m_list[index].time)/(m_list[index+1].time-m_list[index].time); + float t2 = t*t; + float t3 = t*t2; + return m_list[index].value*(2*t3-3*t2+1)+ + m_list[index].deriv*(t3-2*t2+0)+ + m_list[index+1].value*(-2*t3+3*t2)+ + m_list[index+1].deriv*(t3-t2); + + // f(t) = p1 * (2*t^3 - 3*t^2 + 1) + + // r1 * (t^3 - 2*t^2 + t) + + // p2 * (-2*t^3 + 3*t^2) + + // r2 * (t^3 - t^2). } + //--------------------------------------------------------------------------- -void Spline::get_point (size_t index, point &pt) +void Spline::get_point(size_t index, point &pt) { - if (index >= m_list.size()) index = m_list.size() - 1; - pt = m_list[index]; + if (index>=m_list.size()) + index = m_list.size()-1; + pt = m_list[index]; } diff --git a/src/editors/PPEditor/spline.h b/src/editors/PPEditor/spline.h index 1602ea274c6..2ce10746eae 100644 --- a/src/editors/PPEditor/spline.h +++ b/src/editors/PPEditor/spline.h @@ -9,35 +9,41 @@ using namespace std; typedef struct _point { - float value; //значение функции - float deriv; //производная - float time; //время + float value; //значение функции + float deriv; //производная + float time; //время } point; -typedef vector point_list; +typedef vector point_list; typedef vector::iterator point_list_i; class Spline { private: protected: - point_list m_list; - size_t find_point (float time); + point_list m_list; + size_t find_point(float time); public: - Spline (); - ~Spline (); - void add_point (float value, float deriv, float time); - void remove_point (float time); - float get_full_time (); - void reset (); - void clear (); - float get_value (float time); - float get_deriv (float time); - void set_value (float time, float value); - void set_deriv (float time, float deriv); - void create_new (float time); - float calculate_value (float time); - size_t get_points_count () { return m_list.size(); } - void get_point (size_t index, point &pt); + Spline(); + ~Spline(); + void add_point(float value, float deriv, float time); + void remove_point(float time); + float get_full_time(); + void reset(); + void clear(); + float get_value(float time); + float get_deriv(float time); + void set_value(float time, float value); + void set_deriv(float time, float deriv); + void create_new(float time); + float calculate_value(float time); + + size_t get_points_count() + { + return m_list.size(); + } + + void get_point(size_t index, point &pt); }; #endif + diff --git a/src/editors/PPEditor/std.cpp b/src/editors/PPEditor/std.cpp index ac3195a5582..fa2e74a0e27 100644 --- a/src/editors/PPEditor/std.cpp +++ b/src/editors/PPEditor/std.cpp @@ -1,3 +1,3 @@ -#include +#include "xrCore/xrCore.h" #include "PostprocessAnimator.h" - \ No newline at end of file + diff --git a/src/editors/PPEditor/stdafx.h b/src/editors/PPEditor/stdafx.h index 7c46ea68620..8d8f54b5852 100644 --- a/src/editors/PPEditor/stdafx.h +++ b/src/editors/PPEditor/stdafx.h @@ -1,5 +1,5 @@ #define ENGINE_API -#include +#include #include "PostprocessAnimator.h" #include #include