Sorting Network Verify and Draw
Check Whether Comparator Networks Sort and Draw Them
CMain.h
Go to the documentation of this file.
1
3
4// MIT License
5//
6// Copyright (c) 2022 Ian Parberry
7//
8// Permission is hereby granted, free of charge, to any person obtaining a copy
9// of this software and associated documentation files (the "Software"), to
10// deal in the Software without restriction, including without limitation the
11// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12// sell copies of the Software, and to permit persons to whom the Software is
13// furnished to do so, subject to the following conditions:
14//
15// The above copyright notice and this permission notice shall be included in
16// all copies or substantial portions of the Software.
17//
18// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24// IN THE SOFTWARE.
25
26#ifndef __CMAIN_H__
27#define __CMAIN_H__
28
29#include "Includes.h"
30#include "WindowsHelpers.h"
31#include "SortingNetwork.h"
32
37
38class CMain{
39 private:
40 HWND m_hWnd = nullptr;
41 ULONG_PTR m_gdiplusToken = 0;
42 HMENU m_hMenuBar = nullptr;
43
44 std::wstring m_wstrName = L"Default";
45
46 eDrawStyle m_eDrawStyle = eDrawStyle::Horizontal;
47
49
50 void CreateMenus();
51 void EnableMenus();
52
53 public:
54 CMain(const HWND );
55 ~CMain();
56
57 template<class t> void GeneratePowerOf2();
58 template<class t> void Generate();
59 void Read();
60 void Draw();
61 bool Verify();
62
63 void OnPaint();
64 Gdiplus::Bitmap* GetBitmap();
65
66 void SetDrawStyle(const eDrawStyle);
67
68 HRESULT Export(const eExport);
69}; //CMain
70
71#endif //__CMAIN_H__
eDrawStyle
Drawing style.
Definition: Defines.h:34
eExport
Export type.
Definition: Defines.h:42
Useful includes.
Interface for the sorting network CSortingNetwork.
Interface for some helpful Windows-specific functions.
The main class.
Definition: CMain.h:38
void SetDrawStyle(const eDrawStyle)
Set drawing style.
Definition: CMain.cpp:339
void CreateMenus()
Create menus.
Definition: CMain.cpp:130
~CMain()
Destructor.
Definition: CMain.cpp:57
std::wstring m_wstrName
File name.
Definition: CMain.h:44
CMain(const HWND)
Constructor.
Definition: CMain.cpp:46
void Draw()
Draw comparator network to bitmap.
Definition: CMain.cpp:237
void Read()
Read comparator network from file.
Definition: CMain.cpp:169
void GeneratePowerOf2()
Generate sorting network.
Definition: CMain.cpp:215
ULONG_PTR m_gdiplusToken
GDI+ token.
Definition: CMain.h:41
HRESULT Export(const eExport)
Export image file.
Definition: CMain.cpp:246
eDrawStyle m_eDrawStyle
Drawing style.
Definition: CMain.h:46
void EnableMenus()
Enable menus.
Definition: CMain.cpp:144
HMENU m_hMenuBar
Handle to the menu bar.
Definition: CMain.h:42
Gdiplus::Bitmap * GetBitmap()
Get pointer to bitmap.
Definition: CMain.cpp:159
void Generate()
Generate sorting network.
Definition: CMain.cpp:191
void OnPaint()
Paint the client area of the window.
Definition: CMain.cpp:74
CSortingNetwork * m_pSortingNetwork
Pointer to the sorting network.
Definition: CMain.h:48
bool Verify()
Verify that comparator network sorts.
Definition: CMain.cpp:266
HWND m_hWnd
Window handle.
Definition: CMain.h:40
Sorting network.