Skip to content

Commit 182e1ed

Browse files
committed
コードの整形
1 parent 9b01a92 commit 182e1ed

File tree

4 files changed

+91
-69
lines changed

4 files changed

+91
-69
lines changed

curve_editor/ce_curve_id.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ void ce::Curve_ID::add_point(POINT gr_pt)
1414
{
1515
int index = 0;
1616
Point_Address tmp;
17-
if (ctpts.size() >= CE_POINT_MAX) return;
18-
for (int i = 0; i < ctpts.size(); i++) {
17+
if (ctpts.size >= CE_POINT_MAX) return;
18+
for (int i = 0; i < ctpts.size; i++) {
1919
if (ctpts[i].pt_center.x == gr_pt.x)
2020
return;
2121
else if (ctpts[i].pt_center.x > gr_pt.x) {
@@ -55,7 +55,7 @@ void ce::Curve_ID::delete_point(POINT cl_pt)
5555
{
5656
Point_Address address = pt_in_ctpt(cl_pt);
5757
if (!address.position) return;
58-
for (int i = 1; i < ctpts.size() - 1; i++) {
58+
for (int i = 1; i < ctpts.size - 1; i++) {
5959
if (address.index == i) {
6060
ctpts.erase(i);
6161
break;
@@ -201,7 +201,7 @@ void ce::Curve_ID::move_point(Point_Address address, POINT gr_pt, BOOL bReset)
201201
ce::Point_Address ce::Curve_ID::pt_in_ctpt(POINT cl_pt)
202202
{
203203
RECT rcCenter, rcLeft, rcRight;
204-
for (int i = 0; i < ctpts.size(); i++) {
204+
for (int i = 0; i < ctpts.size; i++) {
205205
rcCenter = {
206206
(LONG)to_client(ctpts[i].pt_center).x - CE_POINT_RANGE,
207207
(LONG)to_client(ctpts[i].pt_center).y - CE_POINT_RANGE,
@@ -339,21 +339,21 @@ void ce::Curve_ID::correct_handle(Point_Address address, double angle)
339339
void ce::Curve_ID::reverse_points()
340340
{
341341
std::vector<Points_ID> ctpts_old;
342-
for (int i = 0; i < ctpts.size() / 2.0; i++) {
342+
for (int i = 0; i < ctpts.size / 2.0; i++) {
343343
ctpts_old.emplace_back(ctpts[i]);
344-
ctpts[i].pt_center.x = CE_GR_RES - ctpts[ctpts.size() - i - 1].pt_center.x;
345-
ctpts[i].pt_center.y = CE_GR_RES - ctpts[ctpts.size() - i - 1].pt_center.y;
346-
ctpts[i].pt_left.x = CE_GR_RES - ctpts[ctpts.size() - i - 1].pt_right.x;
347-
ctpts[i].pt_left.y = CE_GR_RES - ctpts[ctpts.size() - i - 1].pt_right.y;
348-
ctpts[i].pt_right.x = CE_GR_RES - ctpts[ctpts.size() - i - 1].pt_left.x;
349-
ctpts[i].pt_right.y = CE_GR_RES - ctpts[ctpts.size() - i - 1].pt_left.y;
350-
351-
ctpts[ctpts.size() - i - 1].pt_center.x = CE_GR_RES - ctpts_old[i].pt_center.x;
352-
ctpts[ctpts.size() - i - 1].pt_center.y = CE_GR_RES - ctpts_old[i].pt_center.y;
353-
ctpts[ctpts.size() - i - 1].pt_left.x = CE_GR_RES - ctpts_old[i].pt_right.x;
354-
ctpts[ctpts.size() - i - 1].pt_left.y = CE_GR_RES - ctpts_old[i].pt_right.y;
355-
ctpts[ctpts.size() - i - 1].pt_right.x = CE_GR_RES - ctpts_old[i].pt_left.x;
356-
ctpts[ctpts.size() - i - 1].pt_right.y = CE_GR_RES - ctpts_old[i].pt_left.y;
344+
ctpts[i].pt_center.x = CE_GR_RES - ctpts[ctpts.size - i - 1].pt_center.x;
345+
ctpts[i].pt_center.y = CE_GR_RES - ctpts[ctpts.size - i - 1].pt_center.y;
346+
ctpts[i].pt_left.x = CE_GR_RES - ctpts[ctpts.size - i - 1].pt_right.x;
347+
ctpts[i].pt_left.y = CE_GR_RES - ctpts[ctpts.size - i - 1].pt_right.y;
348+
ctpts[i].pt_right.x = CE_GR_RES - ctpts[ctpts.size - i - 1].pt_left.x;
349+
ctpts[i].pt_right.y = CE_GR_RES - ctpts[ctpts.size - i - 1].pt_left.y;
350+
351+
ctpts[ctpts.size - i - 1].pt_center.x = CE_GR_RES - ctpts_old[i].pt_center.x;
352+
ctpts[ctpts.size - i - 1].pt_center.y = CE_GR_RES - ctpts_old[i].pt_center.y;
353+
ctpts[ctpts.size - i - 1].pt_left.x = CE_GR_RES - ctpts_old[i].pt_right.x;
354+
ctpts[ctpts.size - i - 1].pt_left.y = CE_GR_RES - ctpts_old[i].pt_right.y;
355+
ctpts[ctpts.size - i - 1].pt_right.x = CE_GR_RES - ctpts_old[i].pt_left.x;
356+
ctpts[ctpts.size - i - 1].pt_right.y = CE_GR_RES - ctpts_old[i].pt_left.y;
357357
}
358358

359359
}
@@ -368,7 +368,7 @@ double ce::Curve_ID::get_value(double ratio, double st, double ed)
368368
if (!ISINRANGE(ratio, 0, 1))
369369
return 0;
370370
// 進捗に相当する区間を調べる
371-
for (int i = 0; i < ctpts.size() - 1; i++) {
371+
for (int i = 0; i < ctpts.size - 1; i++) {
372372
if (ISINRANGE(ratio, ctpts[i].pt_center.x / (double)CE_GR_RES, ctpts[i + 1].pt_center.x / (double)CE_GR_RES)) {
373373
double range = (ctpts[i + 1].pt_center.x - ctpts[i].pt_center.x) / (double)CE_GR_RES;
374374
// 区間ごとの進捗の相対値(0~1)

curve_editor/ce_func_graphics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ void draw_panel_graph(HWND hwnd, HDC hdc_mem, POINT* pt_trace, LPRECT rect_wnd)
361361

362362
//IDモードのとき
363363
else {
364-
for (int i = 0; i < g_curve_id[g_config.id_current].ctpts.size() - 1; i++)
364+
for (int i = 0; i < g_curve_id[g_config.id_current].ctpts.size - 1; i++)
365365
{
366366
//色を指定
367367
pBrush->SetColor(D2D1::ColorF(TO_BGR(CONTRAST(INVERT(g_theme[g_config.theme].bg_graph), CE_GR_POINT_CONTRAST))));

curve_editor/ce_header.hpp

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -103,57 +103,46 @@ namespace ce {
103103
namespace ce {
104104
template <typename T, size_t N>
105105
class StaticArray {
106-
size_t _size;
107-
108106
public:
107+
size_t size;
109108
static const size_t max_size = N;
110109

111110
T elements[N];
112111

113-
StaticArray() : _size(0) {}
112+
StaticArray() : size(0) {}
114113

115114
template <typename U>
116115
T& operator[] (U i) { return elements[MINMAXLIM(i, 0, N - 1)]; }
117116

118-
bool is_max(void)
119-
{
120-
return _size == max_size;
121-
}
122-
123117
void clear(void)
124118
{
125-
_size = 0;
119+
size = 0;
126120
}
127121

128122
void insert(size_t index, const T& v)
129123
{
130-
int max = _size >= max_size ? max_size - 1 : _size;
124+
int max = size >= max_size ? max_size - 1 : size;
131125
for (int i = max; i > (int)index;) {
132126
i--;
133127
elements[i + 1] = elements[i];
134128
}
135129
elements[index] = v;
136-
if (_size < max_size) _size++;
130+
if (size < max_size) size++;
137131
}
138132

139-
void erase(int index)
133+
void push_back(const T& v)
140134
{
141-
_size--;
142-
for (int i = index; i < (int)_size; i++) {
143-
elements[i] = elements[i + 1];
135+
if (size < max_size) {
136+
size++;
137+
elements[size - 1] = v;
144138
}
145139
}
146140

147-
size_t size()
148-
{
149-
return _size;
150-
}
151-
152-
void push_back(const T& v)
141+
void erase(int index)
153142
{
154-
if (_size < max_size) {
155-
_size++;
156-
elements[_size - 1] = v;
143+
size--;
144+
for (int i = index; i < (int)size; i++) {
145+
elements[i] = elements[i + 1];
157146
}
158147
}
159148
};
@@ -176,7 +165,6 @@ namespace ce {
176165

177166
class Curve_ID {
178167
public:
179-
// std::vector<Points_ID> ctpts;
180168
StaticArray <Points_ID, CE_POINT_MAX> ctpts;
181169

182170
Curve_ID()

curve_editor/ce_macro.hpp

Lines changed: 58 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,24 @@
55
//----------------------------------------------------------------------------------
66

77

8+
9+
//---------------------------------------------------------------------
10+
// レイアウト関連
11+
//---------------------------------------------------------------------
12+
// ウィンドウ
813
#define CE_MRG 8
14+
#define CE_MAX_W 1440
15+
#define CE_MAX_H 1280
16+
#define CE_DEF_W 500
17+
#define CE_DEF_H 400
18+
19+
// セパレータ
20+
#define CE_SEPR_DEF 150
21+
#define CE_SEPR_W 8
22+
#define CE_SEPR_LINE_W 4
23+
#define CE_SEPR_LINE_L 32
24+
25+
// グラフ
926
#define CE_GR_PADDING 20
1027
#define CE_GR_RATIO 0.9
1128
#define CE_GR_WHEEL_RATIO 0.1
@@ -17,29 +34,23 @@
1734
#define CE_GR_POINT_TH 0.2
1835
#define CE_GR_POINT_DASH 30
1936
#define CE_GR_POINT_CONTRAST 3
20-
#define CE_MAX_W 1440
21-
#define CE_MAX_H 1280
22-
#define CE_DEF_W 500
23-
#define CE_DEF_H 400
24-
#define CE_SEPR_DEF 150
25-
#define CE_POINT_MAX 64
26-
#define CE_CURVE_MAX 256
37+
#define CE_GR_SCALE_INC 1.01
38+
#define CE_GR_SCALE_MAX 512
39+
#define CE_GR_SCALE_MIN 0.001
40+
41+
// ハンドル・カーブ・制御点
2742
#define CE_HANDLE_DEF_L 50
2843
#define CE_HANDLE_TH 2
2944
#define CE_HANDLE_SIZE 5.8
3045
#define CE_HANDLE_SIRCLE_LINE 2.6
3146
#define CE_POINT_RANGE 10
3247
#define CE_POINT_SIZE 3.2
33-
#define CE_OUTOFRANGE 2122746762
34-
#define CE_GR_SCALE_INC 1.01
35-
#define CE_GR_SCALE_MAX 512
36-
#define CE_GR_SCALE_MIN 0.001
37-
#define CE_SEPR_W 8
38-
#define CE_SEPR_LINE_W 4
39-
#define CE_SEPR_LINE_L 32
4048
#define CE_CURVE_TH 1.2
4149

42-
//コントロール
50+
51+
//---------------------------------------------------------------------
52+
// コントロール
53+
//---------------------------------------------------------------------
4354
#define CE_CT_APPLY 1000
4455
#define CE_CT_MODE_VALUE 1001
4556
#define CE_CT_MODE_ID 1002
@@ -67,7 +78,20 @@
6778
#define CE_WD_PREV_W 30
6879
#define CE_SUBTRACT_LENGTH 10
6980

70-
//明るさ
81+
82+
//---------------------------------------------------------------------
83+
// ウィンドウメッセージ
84+
//---------------------------------------------------------------------
85+
#define CE_WM_REVERSE 2000
86+
#define CE_WM_CHANGEID 2001
87+
#define CE_WM_REDRAW 2002
88+
#define CE_WM_SHOWHANDLE 2003
89+
90+
91+
//---------------------------------------------------------------------
92+
// テーマ関連
93+
//---------------------------------------------------------------------
94+
// 明るさ
7195
#define CE_BR_GRID 25
7296
#define CE_BR_TRACE -10
7397
#define CE_BR_SEPR 256
@@ -76,28 +100,38 @@
76100
#define CE_CT_BR_CLICKED -15
77101
#define CE_CT_BR_SWITCH -20 //unselected
78102

79-
//メッセージ
80-
#define CE_WM_REVERSE 2000
81-
#define CE_WM_CHANGEID 2001
82-
#define CE_WM_REDRAW 2002
83-
#define CE_WM_SHOWHANDLE 2003
84103

104+
//---------------------------------------------------------------------
105+
// その他
106+
//---------------------------------------------------------------------
107+
#define CE_POINT_MAX 64
108+
#define CE_CURVE_MAX 256
109+
#define CE_OUTOFRANGE 2122746762
85110
#define MATH_PI 3.14159265
86111

87-
//正規表現
112+
113+
//---------------------------------------------------------------------
114+
// 正規表現
115+
//---------------------------------------------------------------------
88116
#define CE_REGEX_VALUE R"(^((\d+ *, *)|(\d*\.\d* *, *))((-?\d+ *, *)|(-?\d*\.\d* *, *))((\d+ *, *)|(\d*\.\d* *, *))((-?\d+ *)|(-?\d*\.\d* *))$)"
89117
#define CE_REGEX_FLOW_1 R"()"
90118
#define CE_REGEX_FLOW_2 R"(^\s*\[\s*(\{\s*"name"\s*:\s*".*"\s*,\s*"curve"\s*:\s*\[\s*(\s*-?\d\.?\d+\s*,){3}\s*-?\d\.?\d+\s*\]\s*\},)+\s*\{\s*"name"\s*:\s*".*"\s*,\s*"curve"\s*:\s*\[\s*(\s*-?\d\.?\d+\s*,){3}\s*-?\d\.?\d+\s*\]\s*\}\s*\]\s*$)"
91119
#define CE_REGEX_CEP R"(^(\s*\{\s*".*"(\s*\[\s*-?\d?\.?\d+\s*,\s*-?\d?\.?\d+\s*\]\s*)+\s*\}\s*)+$)"
92120

93-
//フィルタの情報
121+
122+
//---------------------------------------------------------------------
123+
// プラグイン(フィルタ)の情報
124+
//---------------------------------------------------------------------
94125
#define CE_FILTER_NAME "Curve Editor"
95126
#define CE_FILTER_VERSION "v0.1-alpha"
96127
#define CE_FILTER_AUTHOR "mimaraka"
97128
#define CE_FILTER_INFO CE_FILTER_NAME " " CE_FILTER_VERSION " by " CE_FILTER_AUTHOR
98129
#define CE_FILTER_LINK "https://sites.google.com/view/aviutlscripts/home"
99130

100-
//関数マクロ
131+
132+
//---------------------------------------------------------------------
133+
// マクロ関数
134+
//---------------------------------------------------------------------
101135
#define TO_BGR(ref) (RGB(GetBValue(ref), GetGValue(ref), GetRValue(ref)))
102136
#define DISTANCE2(pt1,pt2x, pt2y) (std::sqrt(std::pow((pt2x) - pt1.x, 2) + std::pow((pt2y) - pt1.y, 2)))
103137
#define DISTANCE(pt1,pt2) (std::sqrt(std::pow(pt2.x - pt1.x, 2) + std::pow(pt2.y - pt1.y, 2)))

0 commit comments

Comments
 (0)