Hi,
I've inherited a project that has a "core" of C++ files. Basically, it looks like some standard methods have been cut and pasted into the project.
I've been converting the higher level code to Objective-C and it's going quite well, but I'm at the point where I now need to address some of the low level classes in the core.
Here are the files in question:
sysafx.h
sysafx.cpp
syscore.h
syscore.cpp
sysgraphics.h
sysgraphics.cpp
sysmaths.h
sysmaths.cpp
sysstopwatch.h
sysstopwatch.cpp
sysxml.cpp
Firstly, do the files mean anything to anyone or are they just the names chosen by the last programmer?
Secondly, the sysgraphics module is a class that interfaces to Core Graphics, when it's initialized a CGContextRef is passed in.
Here is a shortened version of the class definition:
class CGraphics
{
public:
CGContextRef &FRef;
CMatrix FMatrix;
float FAlpha;
public:
CGraphics(CGContextRef &ref, const CMatrix &m);
CGContextRef GetContext() const { return FRef; }
void WorldToScreen(float &x, float &y);
void WorldToScreen(float &x, float &y, float &w, float &h);
void DrawLine(float x1, float y1, float x2, float y2);
void DrawBox(float x, float y, float w, float h);
void FillBox(float x, float y, float w, float h);
void DrawTextInBox(float x, float y, float w, float h, const char *str);
void DrawImage(CGImageRef image, const CGRect &rect);
};
And here is a sample method that uses CMatix:
void CGraphics::WorldToScreen(float &x, float &y)
{
CVector3 a(x, y, 0);
a = FMatrix.Transform(a);
x = a.x;
y = a.y;
}
Can anyone offer any ideas or suggestions on the best course of action to convert this?
My initial idea is to make a corresponding Objective-C for "CGraphics" and then change all references CGraphics to use the new class.
Does this sound like a good idea?
Once that was done, I'd have the CMatrix, CVector2 and CVector3 to remaining in C++, which I want gone!!! Also one thing that is going to make it difficult is that there operator overrides in operation which will mean expanding out loads of code in Objective-C. So I could either convert them to Objective-C but it strikes me that CoreGraphics has all this built in.
Would it be better to use this? I'm a bit concerned that the results won't be the same and also I'm not sure what to do for the best.
Any suggestions or idea greatly appreciated.
All the Best
Dave