-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtility.h
More file actions
121 lines (94 loc) · 6.42 KB
/
Utility.h
File metadata and controls
121 lines (94 loc) · 6.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
Copyright(c) 2020 Alain Royer.
Email: aroyer.qc@gmail.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __UTILITY_H__
#define __UTILITY_H__
#include <QtWidgets>
#include <QImage>
#include "typedef.h"
void UpdateComboBox (QComboBox* comboBox);
QString GetFormat (QImage::Format format);
QPoint CenterPoint (QSize Size, QSize MaxSize);
void CheckerPattern (QGraphicsScene* pScene);
QString PrintSize (QSize Size);
QString PrintFileSize (int Count);
QSize GetSizeFromGraphicsView (QGraphicsView* pGraphView, QSize Size);
void setWidgetXY (QWidget* pWidget, int X, int Y);
void setWidgetSize (QWidget* pWidget, int Width, int Height);
QPoint SelectScreenAndCenter (QSize Size);
void ClearTable (QTableWidget* pTable);
QImage::Format AutoSelectConversion (QComboBox* pCombo, QImage::Format Format);
// ---------- Support function for ID_Code ----------
bool getStateID_Code (QVector<uint8_t>* pData, class ID_Code ID);
void setStateID_Code (QVector<uint8_t>* pData, class ID_Code ID);
void clearStateID_Code (QVector<uint8_t>* pData, class ID_Code ID);
int getNextFreeNumber_Up (QVector<uint8_t>* pData, uint32_t ID_Code);
int getNextFreeNumber_Down (QVector<uint8_t>* pData, uint32_t ID_Code);
eWidgetType getTypeImageFromText (QString ID_CodeText);
int getPointSizeFontFromText (QString ID_CodeText);
// ---------- Utility to add other type to uint8_t Vector ----------
uint16_t GetAt_uint16 (QVector<uint8_t>* pData, int i);
uint32_t GetAt_uint32 (QVector<uint8_t>* pData, int i);
void Append_uint16 (QVector<uint8_t>* pData, uint16_t Value);
void Append_uint32 (QVector<uint8_t>* pData, uint32_t Value);
void Insert_uint16 (QVector<uint8_t>* pData, int i, uint16_t Value);
void Insert_uint32 (QVector<uint8_t>* pData, int i, uint32_t Value);
void Replace_uint16 (QVector<uint8_t>* pData, int i, uint16_t Value);
void Replace_uint32 (QVector<uint8_t>* pData, int i, uint32_t Value);
void ChangeEndianAt_uint16 (QVector<uint8_t>* pData, int i);
void ChangeEndianAt_uint32 (QVector<uint8_t>* pData, int i);
// ---------- Load Image in a QImage ----------
void LoadImageFromFile (QImage* pImage, QString PathAndFile);
// ---------- Scaling Image Support Function ----------
void ScaleToRequirement (QImage* pImage, QImage* pProcessedImage, QSize* pSize, eScaler Scale);
void ScaleToFit (QImage* pImage, QImage* pProcessedImage, QSize* pSize);
void ScaleToWidth (QImage* pImage, QImage* pProcessedImage, QSize* pSize);
void ScaleToHeight (QImage* pImage, QImage* pProcessedImage, QSize* pSize);
// ---------- XML Support Function ----------
void SavePathToXML (QString Path);
QString GetPathFromXML ();
void SaveSkinPathToXML (QString Path);
QString GetSkinPathFromXML ();
void SaveDisplaySizeToXML (QSize Size);
QSize GetDisplaySizeFromXML ();
void SaveEndianToXML (eEndianess Endian);
eEndianess GetEndianFromXML ();
// ---------- class for ID_Code ----------
class ID_Code
{
public:
ID_Code (uint32_t Code);
ID_Code (QString CodeText);
ID_Code (eWidgetType Type, int Number);
QString getCodeText () {return m_CodeText;}
QString getPrefix () {return m_Prefix;}
uint32_t getCode () {return m_Code;}
int getNumber () {return m_Number;}
eWidgetType getType () {return m_Type;}
void setNumber (int Number);
void setCodeText (QString CodeText);
private:
void textToCode ();
void codeToText ();
void codeToElement ();
void elementToText ();
QString m_CodeText;
QString m_Prefix;
uint32_t m_Code;
int m_Number;
eWidgetType m_Type;
};
#endif