83{
84 DrawHeader("Custom Math Function");
85 ImGui::Dummy(ImVec2(mathInputWidth + 20, 10));
86 ImGui::SameLine();
87 ImGui::Text("Out");
88 outputPins[0]->Render();
89 ImGui::NewLine();
90 ImGui::Text("Math Input Size : ");
91 ImGui::SameLine();
92 ImGui::PushItemWidth(100);
93 ImGui::DragInt(MAKE_IMGUI_ID(outputPins[0]->id), &mathInputWidth, 0.5f);
94 ImGui::PopItemWidth();
95 inputPins[0]->Render();
96
97 if (inputPins[0]->IsLinked())
98 {
99 ImGui::Text("Factor");
100 }
101
102 else
103 {
104 ImGui::PushItemWidth(100);
105 ImGui::DragFloat(MAKE_IMGUI_ID(inputPins[0]->id), &factor, 0.01f);
106 ImGui::PopItemWidth();
107 }
108
109 ImGui::NewLine();
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141 ImGui::Text("Expression : ");
142 ImGui::SameLine();
143 ImGui::PushItemWidth(mathInputWidth);
144
145 if (ImGui::InputText(MAKE_IMGUI_ID(id), inputExpression, 1024*4))
146 {
147 compiled = false;
148 }
149
150 ImGui::PopItemWidth();
151
152 if (!compiled)
153 {
154 if (ImGui::Button("Compile"))
155 {
156 std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
157 std::wstring wide = converter.from_bytes(inputExpression);
158
159 try
160 {
161#ifdef TERR3D_WIN32
162 parser->SetExpr(wide);
163#else
164 parser->SetExpr(std::string(inputExpression));
165#endif
166 compiled = true;
167 }
168
169 catch (...)
170 {
171 }
172 }
173 }
174}