52 for(UINT pass=0; pass<
m_nInputs/2; pass++){
53 bool bPassUsed =
false;
58 if(dest < m_nInputs && dest > j && !bUsed[j]){
59 bPassUsed = bUsed[j] = bUsed[dest] =
true;
86 const UINT src,
const UINT dest,
const float fDist,
bool bRed)
88 float fSrcy = 0, fDesty = 0, fSrcx = 0, fDestx = 0;
93 case eDrawStyle::Vertical:
96 fSrcy = fDesty = fDist;
100 case eDrawStyle::Horizontal:
101 fSrcx = fDestx = fDist;
108 const int nSrcx = (UINT)std::round(fSrcx);
109 const int nSrcy = (UINT)std::round(fSrcy);
111 const int nDestx = (UINT)std::round(fDestx);
112 const int nDesty = (UINT)std::round(fDesty);
140 if(bRed)fprintf_s(
m_pOutput,
"style=\"fill:red\" ");
141 fprintf_s(
m_pOutput,
"cx=\"%d\" cy=\"%d\"/>", nSrcx, nSrcy);
144 if(bRed)fprintf_s(
m_pOutput,
"style=\"fill:red\" ");
145 fprintf_s(
m_pOutput,
"cx=\"%d\" cy=\"%d\"/>", nDestx, nDesty);
148 if(bRed)fprintf_s(
m_pOutput,
"style=\"stroke:red\" ");
149 fprintf_s(
m_pOutput,
"x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\"/>\n",
150 nSrcx, nSrcy, nDestx, nDesty);
157 const UINT nLen = abs(nDestx - nSrcx + nDesty - nSrcy);
159 fprintf_s(
m_pOutput,
"\\put(%d,-%d){\\circle*{%d}}\n", nSrcx, nSrcy, d);
160 fprintf_s(
m_pOutput,
"\\put(%d,-%d){\\circle*{%d}}\n", nDestx, nDesty, d);
161 fprintf_s(
m_pOutput,
"\\put(%d,-%d){\\line(%d,%d){%u}}\n", nDestx, nDesty,
186 for(UINT pass=0; pass<
m_nInputs/2; pass++){
187 bool bPassUsed =
false;
190 case eDrawStyle::Vertical:
194 if(dest < m_nInputs && dest > j && !bUsed[j]){
197 bPassUsed = bUsed[j] = bUsed[dest] =
true;
203 case eDrawStyle::Horizontal:
207 if(dest <
m_nInputs && dest < (UINT)j && !bUsed[dest]){
210 bPassUsed = bUsed[j] = bUsed[dest] =
true;
235 float fSrcy = 0, fDesty = 0, fSrcx = 0, fDestx = 0;
239 case eDrawStyle::Vertical:
240 fSrcy = 0.0f; fDesty = fLen;
245 case eDrawStyle::Horizontal:
246 fSrcx = 0.0f; fDestx = fLen;
252 const int nLen = (UINT)std::round(fLen);
255 const int nSrcx = (UINT)std::round(fSrcx);
256 const int nSrcy = (UINT)std::round(fSrcy);
258 const int nDestx = (UINT)std::round(fDestx);
259 const int nDesty = (UINT)std::round(fDesty);
269 fprintf_s(
m_pOutput,
"<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\"/>\n",
270 nSrcx, nSrcy, nDestx, nDesty);
275 fprintf_s(
m_pOutput,
"\\put(%d,-%d){\\line(%d,%d){%d}}\n",
276 nSrcx, nSrcy, vx, vy, nLen);
281 case eDrawStyle::Vertical: fSrcx +=
m_fXDelta; fDestx = fSrcx;
break;
282 case eDrawStyle::Horizontal: fSrcy +=
m_fXDelta; fDesty = fSrcy;
break;
305 case eDrawStyle::Vertical:
m_pBitmap =
new Gdiplus::Bitmap(w, h);
break;
306 case eDrawStyle::Horizontal:
m_pBitmap =
new Gdiplus::Bitmap(h, w);
break;
310 m_pGraphics->SetSmoothingMode(Gdiplus::SmoothingModeHighQuality);
312 m_pPen =
new Gdiplus::Pen(Gdiplus::Color::Black);
313 m_pRedPen =
new Gdiplus::Pen(Gdiplus::Color::Red);
316 m_pBrush =
new Gdiplus::SolidBrush(Gdiplus::Color::Black);
317 m_pRedBrush =
new Gdiplus::SolidBrush(Gdiplus::Color::Red);
340 m_pBitmap->Save(lpwstr, &clsid,
nullptr);
363 fprintf_s(
m_pOutput,
"\\setlength{\\unitlength}{0.5pt}\n");
366 case eDrawStyle::Vertical:
367 fprintf_s(
m_pOutput,
"\\begin{picture}(%u,%u)(0,-%u)\n", w, h, h);
370 case eDrawStyle::Horizontal:
371 fprintf_s(
m_pOutput,
"\\begin{picture}(%u,%u)(0,-%u)\n", h, w, w);
384 fprintf_s(
m_pOutput,
"\\end{picture}\n");
409 fprintf_s(
m_pOutput,
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
418 case eDrawStyle::Vertical:
419 fprintf_s(
m_pOutput,
"<svg width=\"%u\" height=\"%u\" ", w + 8, h + 8);
420 fprintf_s(
m_pOutput,
"viewBox=\"-4 -4 %u %u\" ", w + 8, h + 8);
423 case eDrawStyle::Horizontal:
424 fprintf_s(
m_pOutput,
"<svg width=\"%u\" height=\"%u\" ", h + 8, w + 8);
425 fprintf_s(
m_pOutput,
"viewBox=\"-4 -4 %u %u\" ", h + 8, w + 8);
429 fprintf_s(
m_pOutput,
"xmlns=\"http://www.w3.org/2000/svg\">\n");
Interface for the renderable comparator network CRenderableComparatorNet.
HRESULT GetEncoderClsid(const WCHAR *format, CLSID *pClsid)
Get encoder CLSID.
Interface for some helpful Windows-specific functions.
UINT ** m_nMatch
Matchings at each level.
bool m_bSorts
True if it sorts, false if it doesn't or unknown.
UINT m_nInputs
Number of inputs.
bool ** m_bUsed
Whether comparators are used when sorting.
const Gdiplus::REAL m_fYDelta2
Extra vertical gap between layers in pixels.
HRESULT ExportToSVG(LPWSTR)
Export in SVG format.
void DrawComparator(const UINT, const UINT, const float, bool=false)
Draw a comparator.
Gdiplus::Pen * m_pRedPen
Pointer to graphics pen.
HRESULT ExportToTex(LPWSTR)
Export in TeX format.
Gdiplus::Bitmap * GetBitmap()
Get bitmap pointer.
FILE * m_pOutput
File pointer.
Gdiplus::SolidBrush * m_pBrush
Pointer to graphics brush.
const Gdiplus::REAL m_fPenWidth
Pen width in pixels.
HRESULT ExportToPNG(LPWSTR)
Export in PNG format.
Gdiplus::Bitmap * m_pBitmap
Pointer to a bitmap image.
const Gdiplus::REAL m_fDiameter
Diameter of circles in pixels.
Gdiplus::REAL ComputeBitmapHeight()
Compute bitmap height.
Gdiplus::SolidBrush * m_pRedBrush
Pointer to graphics brush.
Gdiplus::Pen * m_pPen
Pointer to graphics pen.
Gdiplus::Graphics * m_pGraphics
Pointer to graphics object.
void DrawChannels(const float fLen)
Draw channels.
const Gdiplus::REAL m_fXDelta
Gap between channels in pixels.
const Gdiplus::REAL m_fYDelta
Vertical comparator gap in pixels.
eDrawStyle m_eDrawStyle
Drawing style.
void Draw(const eDrawStyle)
Draw to a Gdiplus::Bitmap.
eExport m_eExportType
Export type.
~CRenderableComparatorNet()
Destructor.
void DrawComparators()
Draw all comparators.