Skip to content

Commit f23abf1

Browse files
committed
xrEProps: NumericVector seems to be ported. Needs testing
Add C++Builder-specific code ShaderFunction (just as a template)
1 parent b186ebf commit f23abf1

File tree

4 files changed

+98
-16
lines changed

4 files changed

+98
-16
lines changed

src/editors/xrECore/Props/NumericVector.cpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ bool NumericVector::Run(pcstr title, Fvector* data, int decimal, Fvector* resetV
1313
this->Text = str;
1414
Value = data;
1515
ResetValue = resetValue;
16+
buttonReset->Enabled = !!resetValue;
17+
18+
numX->DecimalPlaces = decimal;
19+
numY->DecimalPlaces = decimal;
20+
numZ->DecimalPlaces = decimal;
21+
22+
numX->Value = (Decimal)data->x;
23+
numY->Value = (Decimal)data->y;
24+
numZ->Value = (Decimal)data->z;
1625

1726
if (min)
1827
{
@@ -42,7 +51,25 @@ bool NumericVector::Run(pcstr title, Fvector* data, int decimal, Fvector* resetV
4251

4352
}
4453

45-
buttonReset_Click(nullptr, nullptr);
54+
if (!X || !Y)
55+
{
56+
POINT pt;
57+
GetCursorPos(&pt);
58+
int w = GetSystemMetrics(SM_CXSCREEN);
59+
int h = GetSystemMetrics(SM_CYSCREEN);
60+
Left = pt.x - (Width * 0.5f);
61+
Top = pt.y;
62+
if (((Left + Width * 0.5f) > w) || ((Top + Height) > h))
63+
{
64+
Left = w * 0.5f - Width * 0.5f;
65+
Top = h * 0.5f;
66+
}
67+
}
68+
else
69+
{
70+
Left = *X - (Width * 0.5f);
71+
Top = *Y;
72+
}
4673

4774
numX->ValueChanged += gcnew EventHandler(this, &NumericVector::OnValueChanged);
4875

src/editors/xrECore/Props/NumericVector.h

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ namespace XRay
44
{
55
namespace ECore
66
{
7+
namespace Props
8+
{
79
ref class NumericVector;
810
}
911
}
12+
}
1013

1114
template <class T>
1215
struct _vector3;
@@ -44,23 +47,30 @@ public ref class NumericVector : public System::Windows::Forms::Form
4447
}
4548
}
4649

50+
private: System::Void buttonApply_Click(System::Object^ sender, System::EventArgs^ e);
51+
private: System::Void buttonOk_Click(System::Object^ sender, System::EventArgs^ e);
52+
private: System::Void buttonCancel_Click(System::Object^ sender, System::EventArgs^ e);
53+
private: System::Void buttonReset_Click(System::Object^ sender, System::EventArgs^ e);
54+
private: System::Void buttonImmediate_Click(System::Object^ sender, System::EventArgs^ e);
55+
private: System::Void NumericVector_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e);
56+
57+
private: System::Void OnValueChanged(System::Object^ sender, System::EventArgs^ e);
58+
59+
4760
private: Fvector* Value;
4861
private: Fvector* ResetValue;
4962
private: System::Windows::Forms::Button^ buttonOk;
5063
private: System::Windows::Forms::Button^ buttonCancel;
51-
private: System::Windows::Forms::Button^ buttonReset;
64+
private: System::Windows::Forms::Button^ buttonReset;
65+
private: System::Windows::Forms::Button^ buttonApply;
66+
private: System::Windows::Forms::Button^ buttonImmediate;
67+
private: System::Windows::Forms::CheckBox^ checkImmediate;
5268
private: XRay::SdkControls::NumericSpinner^ numX;
5369
private: XRay::SdkControls::NumericSpinner^ numY;
5470
private: XRay::SdkControls::NumericSpinner^ numZ;
5571
private: System::Windows::Forms::Label^ labelX;
5672
private: System::Windows::Forms::Label^ labelY;
5773
private: System::Windows::Forms::Label^ labelZ;
58-
private: System::Windows::Forms::Button^ button1;
59-
private: System::Windows::Forms::Button^ button2;
60-
private: System::Windows::Forms::CheckBox^ checkImmediate;
61-
62-
private: System::Windows::Forms::Button^ buttonApply;
63-
private: System::Windows::Forms::Button^ buttonImmediate;
6474

6575
private:
6676
System::ComponentModel::Container^ components;
@@ -199,14 +209,6 @@ private: System::Windows::Forms::Button^ buttonImmediate;
199209

200210
}
201211
#pragma endregion
202-
private: System::Void buttonApply_Click(System::Object^ sender, System::EventArgs^ e);
203-
private: System::Void buttonOk_Click(System::Object^ sender, System::EventArgs^ e);
204-
private: System::Void buttonCancel_Click(System::Object^ sender, System::EventArgs^ e);
205-
private: System::Void buttonReset_Click(System::Object^ sender, System::EventArgs^ e);
206-
private: System::Void buttonImmediate_Click(System::Object^ sender, System::EventArgs^ e);
207-
private: System::Void NumericVector_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e);
208-
209-
private: System::Void OnValueChanged(System::Object^ sender, System::EventArgs^ e);
210212
};
211213
} // namespace Props
212214
} // namespace ECore

src/editors/xrECore/Props/ShaderFunction.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,56 @@ void ShaderFunction::DrawGraph()
132132

133133
// XXX: Draw
134134
//System::Windows::Controls::Canvas canvas;
135+
136+
#if 0 // Taken from xrEProps/ShaderFunction.cpp
137+
int w = imDraw->Width - 4;
138+
int h = imDraw->Height - 4;
139+
140+
TRect r;
141+
r.Left = 0;
142+
r.Top = 0;
143+
r.Right = w + 4;
144+
r.Bottom = h + 4;
145+
TCanvas* C = imDraw->Canvas;
146+
C->Brush->Color = clBlack;
147+
C->FillRect(r);
148+
C->Pen->Color = TColor(0x00006600);
149+
// draw center
150+
C->Pen->Color = clLime;
151+
C->Pen->Style = psDot;
152+
C->MoveTo(2, h / 2 + 2);
153+
C->LineTo(w + 2, h / 2 + 2);
154+
// draw rect
155+
C->Pen->Color = TColor(0x00006600);
156+
C->Pen->Style = psSolid;
157+
C->MoveTo(0, 0);
158+
C->LineTo(w + 3, 0);
159+
C->LineTo(w + 3, h + 3);
160+
C->LineTo(0, h + 3);
161+
C->LineTo(0, 0);
162+
// draw graph
163+
C->Pen->Color = clYellow;
164+
165+
float t_cost = 1.f / w;
166+
float tm = 0;
167+
float y = m_CurFunc->Calculate(tm) - m_CurFunc->arg[0];
168+
float delta = m_CurFunc->arg[1] * 2;
169+
delta = delta ? (h / delta) : 0;
170+
float yy = h - (delta * y + h / 2);
171+
C->MoveTo(2, yy + 2);
172+
for (int t = 1; t < w; t++)
173+
{
174+
tm = seScale->Value * t * t_cost / (fis_zero(m_CurFunc->arg[3]) ? 1.f : m_CurFunc->arg[3]);
175+
y = m_CurFunc->Calculate(tm) - m_CurFunc->arg[0];
176+
yy = h - (delta * y + h / 2);
177+
C->LineTo(t + 2, yy + 2);
178+
}
179+
// draw X-axis
180+
C->Pen->Color = clGreen;
181+
float AxisX = h - (delta * (-m_CurFunc->arg[0]) + h / 2);
182+
C->MoveTo(2, AxisX + 2);
183+
C->LineTo(w + 2, AxisX + 2);
184+
#endif
135185
}
136186
} // namespace Props
137187
} // namespace ECore

src/editors/xrECore/Props/ShaderFunction.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ namespace XRay
44
{
55
namespace ECore
66
{
7+
namespace Props
8+
{
79
ref class ShaderFunction;
810
}
911
}
12+
}
1013

1114
struct WaveForm;
1215
struct xr_token;

0 commit comments

Comments
 (0)