Skip to content

Commit 0808cba

Browse files
refactor: whole structure
1 parent b585b8c commit 0808cba

7 files changed

Lines changed: 23 additions & 124 deletions

File tree

FreeFrame/Components/Importer.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,12 @@ static private (List<Shape>, SortedDictionary<int, List<Shape>>, bool) ImportFro
2222

2323
using (XmlReader reader = XmlReader.Create(pStream))
2424
{
25-
26-
25+
try
26+
{
2727
while (reader.Read())
2828
{
2929
if (reader.HasAttributes)
3030
{
31-
//Console.WriteLine("Attributes of <" + reader.Name + ">");
3231
switch (reader.Name)
3332
{
3433
case "xml":
@@ -61,9 +60,6 @@ static private (List<Shape>, SortedDictionary<int, List<Shape>>, bool) ImportFro
6160
}
6261

6362
}
64-
// TODO: Fix trycatch
65-
try
66-
{
6763
}
6864
catch (Exception)
6965
{

FreeFrame/Components/Shapes/Path/DrawAttribute.cs

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -839,77 +839,4 @@ public override void UpdateLast()
839839
}
840840
}
841841
}
842-
843-
/// <summary>
844-
/// EllipticalArc, Elliptical Arc Curve, A or a.
845-
/// Use to draw an ellipse.
846-
/// More info: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#elliptical_arc_curve
847-
/// </summary>
848-
public class EllipticalArc : DrawAttribute
849-
{
850-
int _rx;
851-
int _ry;
852-
int _angle;
853-
bool _largeArcFlag;
854-
bool _sweepFlag;
855-
856-
public EllipticalArc() { }
857-
858-
/// <summary>
859-
/// Use to draw an ellipse.
860-
/// </summary>
861-
/// <param name="rx">radius x of the ellipse</param>
862-
/// <param name="ry">radius y of the ellipse</param>
863-
/// <param name="angle">rotation (in degrees) relative to the x-axis</param>
864-
/// <param name="largeArcFlag">either 0 (large arc) or 1 (small arc)</param>
865-
/// <param name="sweepFlag">either 0 (clockwise arc) or 1 (counterclockwise arc)</param>
866-
/// <param name="x">new current point x</param>
867-
/// <param name="y">new current point y</param>
868-
/// <param name="isRelative">if true, the points becames relatives to the last point</param>
869-
public EllipticalArc(Group rx, Group ry, Group angle, Group largeArcFlag, Group sweepFlag, Group x, Group y, bool isRelative = false) : this(Convert.ToInt32(rx.Value), Convert.ToInt32(ry.Value), Convert.ToInt32(angle.Value), Convert.ToInt32(largeArcFlag.Value) == 0 ? false : true, Convert.ToInt32(sweepFlag.Value) == 0 ? false : true, Convert.ToInt32(x.Value), Convert.ToInt32(y.Value), isRelative) { }
870-
871-
/// <summary>
872-
/// Use to draw an ellipse.
873-
/// </summary>
874-
/// <param name="rx">radius x of the ellipse</param>
875-
/// <param name="ry">radius y of the ellipse</param>
876-
/// <param name="angle">rotation (in degrees) relative to the x-axis</param>
877-
/// <param name="largeArcFlag">either 0 (large arc) or 1 (small arc)</param>
878-
/// <param name="sweepFlag">either 0 (clockwise arc) or 1 (counterclockwise arc)</param>
879-
/// <param name="x">new current point x</param>
880-
/// <param name="y">new current point y</param>
881-
/// <param name="isRelative">if true, the points becames relatives to the last point</param>
882-
public EllipticalArc(int rx, int ry, int angle, bool largeArcFlag, bool sweepFlag, int x, int y, bool isRelative = false)
883-
{
884-
_rx = rx;
885-
_ry = ry;
886-
_angle = angle;
887-
_largeArcFlag = largeArcFlag;
888-
_sweepFlag = sweepFlag;
889-
X = x;
890-
Y = y;
891-
IsRelative = isRelative;
892-
}
893-
894-
public override List<Vector2i> GetSelectablePoints()
895-
{
896-
throw new NotImplementedException();
897-
}
898-
899-
public override float[] GetVertices()
900-
{
901-
throw new NotImplementedException();
902-
}
903-
public override uint[] GetVerticesIndexes()
904-
{
905-
throw new NotImplementedException();
906-
}
907-
908-
public override string ToString() => String.Format("{0} {1} {2} {3} {4} {5} {6},{7}", IsRelative ? 'a' : 'A', _rx, _ry, _angle, Convert.ToInt32(_largeArcFlag), Convert.ToInt32(_sweepFlag), X, Y);
909-
910-
public override void UpdateLast()
911-
{
912-
throw new NotImplementedException();
913-
}
914-
}
915842
}

FreeFrame/Components/Shapes/SVGPath.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@ public SVGPath(XmlReader reader)
8181
case 't':
8282
DrawAttributes.Add(new SmoothQuadraticBezierCurveTo(match.Groups[1], match.Groups[2], c == 't')); // 't' is relative and 'T' absolute
8383
break;
84-
case 'a':
85-
DrawAttributes.Add(new EllipticalArc(match.Groups[1], match.Groups[2], match.Groups[3], match.Groups[4], match.Groups[5], match.Groups[6], match.Groups[7], c == 'a')); // 'a' is relative and 'A' absolute
86-
break;
8784
case 'z':
8885
DrawAttributes.Add(new LineTo(_x0, _y0));
8986
break;
@@ -158,7 +155,6 @@ public override void Move(Vector2i position)
158155
Type attrType = attr.GetType();
159156
if (attr.IsRelative == false) // Update position of each absolute attr
160157
{
161-
//Console.WriteLine("{0} is relative? =>{1}", attr.GetType().Name, attr.IsRelative);
162158
if (deltaX == null || deltaY == null)
163159
{
164160
// Get delta X and Y only one time
@@ -185,8 +181,7 @@ public override void Move(Vector2i position)
185181
if (attrType == typeof(CurveTo) ||
186182
attrType == typeof(SmoothCurveTo) ||
187183
attrType == typeof(QuadraticBezierCurveTo) ||
188-
attrType == typeof(SmoothQuadraticBezierCurveTo) ||
189-
attrType == typeof(EllipticalArc)) // Only thoses are LineStrip type
184+
attrType == typeof(SmoothQuadraticBezierCurveTo)) // Only thoses are LineStrip type
190185
{
191186
Renderers.Add(new Renderer(attr.GetVertices(), attr.GetVerticesIndexes(), PrimitiveType.LineStrip, this));
192187
}

FreeFrame/Lib/ImGuiTools/ImGuiController.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,6 @@ private void RenderImDrawData(ImDrawDataPtr draw_data)
284284
int newSize = (int)Math.Max(_vertexBufferSize * 1.5f, vertexSize);
285285
GL.NamedBufferData(_vertexBuffer, newSize, IntPtr.Zero, BufferUsageHint.DynamicDraw);
286286
_vertexBufferSize = newSize;
287-
288-
Console.WriteLine($"Resized dear imgui vertex buffer to new size {_vertexBufferSize}");
289287
}
290288

291289
int indexSize = cmd_list.IdxBuffer.Size * sizeof(ushort);
@@ -294,8 +292,6 @@ private void RenderImDrawData(ImDrawDataPtr draw_data)
294292
int newSize = (int)Math.Max(_indexBufferSize * 1.5f, indexSize);
295293
GL.NamedBufferData(_indexBuffer, newSize, IntPtr.Zero, BufferUsageHint.DynamicDraw);
296294
_indexBufferSize = newSize;
297-
298-
Console.WriteLine($"Resized dear imgui index buffer to new size {_indexBufferSize}");
299295
}
300296
}
301297

FreeFrame/Renderer.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,13 @@ public void ImplementObjects(float[] vertices, uint[] indexes)
165165
_indexCount = indexes.Length;
166166
}
167167
/// <summary>
168-
/// Delete all the buffer objects and shader
168+
/// Delete all the buffer objects
169169
/// </summary>
170170
public void DeleteObjects()
171171
{
172172
GL.DeleteBuffer(VertexBufferObjectID);
173173
GL.DeleteBuffer(IndexBufferObjectID);
174174
GL.DeleteVertexArray(VertexArrayObjectID);
175-
_shader.Delete();
176175
}
177176
}
178177
}

FreeFrame/Shader.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,5 @@ int CompileShader(string uri, ShaderType type)
6161
/// Use the current shaders
6262
/// </summary>
6363
public void Use() => GL.UseProgram(_program);
64-
65-
/// <summary>
66-
/// Delete the program/shaders
67-
/// </summary>
68-
public void Delete() { } //GL.DeleteProgram(_program);
69-
~Shader() => Delete();
70-
//TODO: Make deletion program correctly
7164
}
7265
}

FreeFrame/Window.cs

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,6 @@ private void ShowUI()
714714
_selectedShape = Shapes[i];
715715
_selector.Select(Shapes[i]);
716716
_userMode = UserMode.Edit;
717-
Console.WriteLine("New shape selected through tree view");
718717
}
719718
if (i - 1 >= 0)
720719
{
@@ -945,7 +944,6 @@ private void ShowUI()
945944
{
946945
if (shape.Id == _selectedShape.Id)
947946
{
948-
Console.WriteLine("Already exist");
949947
_timeline.SortedTimeline[_timeline.TimelineIndex].Remove(shape);
950948
break;
951949
}
@@ -1094,36 +1092,31 @@ private void ShowUI()
10941092
if (picker.Draw())
10951093
{
10961094
ResetSelection();
1097-
//bool compatibilityFlag = false;
1098-
1099-
switch (_importMode)
1100-
{
1101-
case ImportMode.Workspace:
1102-
ImportFreeFrameWorkspace(picker.SelectedFile);
1103-
break;
1104-
case ImportMode.Add:
1105-
(List<Shape> newShapes, SortedDictionary<int, List<Shape>> newTimeline, _dialogCompatibility) = Importer.ImportFromFile(picker.SelectedFile);
1106-
Shapes.AddRange(newShapes);
1107-
break;
1108-
case ImportMode.Override:
1109-
(Shapes, _timeline.SortedTimeline, _dialogCompatibility) = Importer.ImportFromFile(picker.SelectedFile);
1110-
_timeline.ResetTimeline();
1111-
break;
1112-
default:
1113-
break;
1114-
}
1115-
// TODO: Fix trycatch
11161095
try
11171096
{
1097+
switch (_importMode)
1098+
{
1099+
case ImportMode.Workspace:
1100+
ImportFreeFrameWorkspace(picker.SelectedFile);
1101+
break;
1102+
case ImportMode.Add:
1103+
(List<Shape> newShapes, SortedDictionary<int, List<Shape>> newTimeline, _dialogCompatibility) = Importer.ImportFromFile(picker.SelectedFile);
1104+
Shapes.AddRange(newShapes);
1105+
break;
1106+
case ImportMode.Override:
1107+
(Shapes, _timeline.SortedTimeline, _dialogCompatibility) = Importer.ImportFromFile(picker.SelectedFile);
1108+
_timeline.ResetTimeline();
1109+
break;
1110+
default:
1111+
break;
1112+
}
1113+
11181114
}
11191115
catch (Exception)
11201116
{
11211117
_dialogError = true;
11221118
}
11231119

1124-
//if (compatibilityFlag)
1125-
// _dialogCompatibility = true;
1126-
11271120
FilePicker.Clear();
11281121
}
11291122
_dialogFilePicker = false;
@@ -1134,7 +1127,7 @@ private void ShowUI()
11341127
if (_dialogCompatibility)
11351128
ImGui.OpenPopup("Compatibility Problem");
11361129

1137-
if (ImGui.BeginPopupModal("Compatibility Problem")) // ImGuiWindowFlags.AlwaysAutoResize
1130+
if (ImGui.BeginPopupModal("Compatibility Problem"))
11381131
{
11391132
ImGui.Text("Some SVG elements are not compatible. Go to the list of compatible SVG elements");
11401133
ImGui.Separator();
@@ -1149,7 +1142,7 @@ private void ShowUI()
11491142
// Error alert
11501143
if (_dialogError)
11511144
ImGui.OpenPopup("Error Problem");
1152-
if (ImGui.BeginPopupModal("Error Problem")) // ImGuiWindowFlags.AlwaysAutoResize
1145+
if (ImGui.BeginPopupModal("Error Problem"))
11531146
{
11541147
ImGui.Text("There was an error while importing the file, please check the syntax");
11551148
ImGui.Separator();

0 commit comments

Comments
 (0)