@phoenix-wing/code-core 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/NOTICE +4 -0
- package/README.md +14 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/pnwCaaDialogHandoff.d.ts +17 -0
- package/dist/pnwCaaDialogHandoff.d.ts.map +1 -0
- package/dist/pnwCaaDialogHandoff.js +34 -0
- package/dist/pnwCaaDialogHandoff.js.map +1 -0
- package/dist/pnwCaaEnvironment.d.ts +17 -0
- package/dist/pnwCaaEnvironment.d.ts.map +1 -0
- package/dist/pnwCaaEnvironment.js +23 -0
- package/dist/pnwCaaEnvironment.js.map +1 -0
- package/dist/pnwCodeRenamePlan.d.ts +47 -0
- package/dist/pnwCodeRenamePlan.d.ts.map +1 -0
- package/dist/pnwCodeRenamePlan.js +105 -0
- package/dist/pnwCodeRenamePlan.js.map +1 -0
- package/dist/pnwFileResultTree.d.ts +25 -0
- package/dist/pnwFileResultTree.d.ts.map +1 -0
- package/dist/pnwFileResultTree.js +37 -0
- package/dist/pnwFileResultTree.js.map +1 -0
- package/dist/pnwReorderCpp.d.ts +7 -0
- package/dist/pnwReorderCpp.d.ts.map +1 -0
- package/dist/pnwReorderCpp.js +389 -0
- package/dist/pnwReorderCpp.js.map +1 -0
- package/dist/pnwReorderHeader.d.ts +21 -0
- package/dist/pnwReorderHeader.d.ts.map +1 -0
- package/dist/pnwReorderHeader.js +896 -0
- package/dist/pnwReorderHeader.js.map +1 -0
- package/dist/pnwUuid.d.ts +25 -0
- package/dist/pnwUuid.d.ts.map +1 -0
- package/dist/pnwUuid.js +140 -0
- package/dist/pnwUuid.js.map +1 -0
- package/dist/pnwUuidReplacementPlan.d.ts +57 -0
- package/dist/pnwUuidReplacementPlan.d.ts.map +1 -0
- package/dist/pnwUuidReplacementPlan.js +101 -0
- package/dist/pnwUuidReplacementPlan.js.map +1 -0
- package/dist/pnwWorkset.d.ts +20 -0
- package/dist/pnwWorkset.d.ts.map +1 -0
- package/dist/pnwWorkset.js +51 -0
- package/dist/pnwWorkset.js.map +1 -0
- package/package.json +50 -0
- package/src/fixtures/annotation_sep.cpp +27 -0
- package/src/fixtures/caa2_wizard_section.h +17 -0
- package/src/fixtures/clang_format_class_tail.h +23 -0
- package/src/fixtures/clang_format_doubled.h +16 -0
- package/src/fixtures/clang_format_nested_markers.h +24 -0
- package/src/fixtures/clang_format_off_on.h +18 -0
- package/src/fixtures/internal_calls.cpp +29 -0
- package/src/fixtures/kevin_wizard_section.h +23 -0
- package/src/fixtures/ktalarmclock.clang-format.yaml +57 -0
- package/src/fixtures/ktca_KTCAutoCodeFrm_KTCAutoCodeUI.m_src_KTCAutoDialog.cpp +242 -0
- package/src/fixtures/ktca_KTCAutoCodeFrm_PublicInterfaces_KTCAutoDialog.h +165 -0
- package/src/fixtures/ktca_KTCAutoCodeInterfaces_KTCAutoCodeItf.m_src_KTCAutoAttrAccess.cpp +423 -0
- package/src/fixtures/ktca_KTCAutoCodeInterfaces_KTCAutoCodeItf.m_src_KTCAutoBuildGSM.cpp +105 -0
- package/src/fixtures/ktca_KTCAutoCodeInterfaces_KTCAutoCodeItf.m_src_KTCAutoPartDoc.cpp +121 -0
- package/src/fixtures/ktca_KTCAutoCodeInterfaces_PublicInterfaces_KTCAutoAttrAccess.h +310 -0
- package/src/fixtures/ktca_KTCAutoCodeInterfaces_PublicInterfaces_KTCAutoBuildGSM.h +56 -0
- package/src/fixtures/ktca_KTCAutoCodeInterfaces_PublicInterfaces_KTCAutoCatalogParam.h +52 -0
- package/src/fixtures/ktca_KTCAutoCodeInterfaces_PublicInterfaces_KTCAutoGSM.h +91 -0
- package/src/fixtures/ktca_KTCAutoCodeInterfaces_PublicInterfaces_KTCAutoPartDoc.h +106 -0
- package/src/fixtures/pnx_bom_analysis_cmd_min.cpp +72 -0
- package/src/fixtures/pnx_bom_analysis_param_min.h +49 -0
- package/src/fixtures/pnx_bom_param_system_split.h +39 -0
- package/src/fixtures/pnx_caa2_widget_decl.h +19 -0
- package/src/fixtures/pragma_region.h +18 -0
- package/src/index.ts +78 -0
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Shanghai Kuntai Software Technology Co., Ltd. 2025
|
|
3
|
+
* @license MIT
|
|
4
|
+
* @author Phoenix Wing
|
|
5
|
+
* @checkout KTCAutoCode
|
|
6
|
+
* @file KTCAutoAttrAccess.cpp
|
|
7
|
+
* @version V1.0
|
|
8
|
+
* @date 2025-12-17
|
|
9
|
+
* @brief
|
|
10
|
+
*/
|
|
11
|
+
// CAT
|
|
12
|
+
#include "CATIDescendants.h"
|
|
13
|
+
#include "CATIMfBRep.h"
|
|
14
|
+
#include "iostream.h"
|
|
15
|
+
|
|
16
|
+
// auto code
|
|
17
|
+
#include "KTCAutoAttrAccess.h"
|
|
18
|
+
#include "KTCAutoDefine.h"
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @brief ���CATICkeInst_var ckeInst
|
|
22
|
+
* @param TYPE ���������磺String��Double��IntBoolean
|
|
23
|
+
*/
|
|
24
|
+
#define GET_CATICkeInst_DEFAULT(DEFAULT) \
|
|
25
|
+
CATICkeInst_var ckeInst = get_CATICkeInst(name); \
|
|
26
|
+
if (NULL_var == ckeInst) { \
|
|
27
|
+
value = DEFAULT; \
|
|
28
|
+
return E_FAIL; \
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @brief ���CATISpecAttrKey* attrKey
|
|
33
|
+
* @param DEFAULT Ĭ��ֵ
|
|
34
|
+
*/
|
|
35
|
+
#define GET_CATISpecAttrKey_DEFAULT(DEFAULT) \
|
|
36
|
+
CATISpecAttrKey* attrKey = get_CATISpecAttrKey(name); \
|
|
37
|
+
if (NULL == attrKey) { \
|
|
38
|
+
value = DEFAULT; \
|
|
39
|
+
return E_FAIL; \
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @brief ͨ��pecAttrKey ���ֵ
|
|
44
|
+
* @param DEFAULT Ĭ��ֵ
|
|
45
|
+
* @param TYPE �������ͣ����磺int,double,CATUnicodeString ...
|
|
46
|
+
*/
|
|
47
|
+
#define GET_VALUE_FROM_SpecAttrKey(DEFAULT, TYPE) \
|
|
48
|
+
CATISpecAttrKey* attrKey = get_CATISpecAttrKey(name); \
|
|
49
|
+
if (NULL == attrKey) { \
|
|
50
|
+
value = DEFAULT; \
|
|
51
|
+
return E_FAIL; \
|
|
52
|
+
} \
|
|
53
|
+
value = attrAccess_->Get##TYPE(attrKey); \
|
|
54
|
+
KTCRelease(attrKey)
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @brief ͨ��CkePar �趨ֵ
|
|
58
|
+
* @param TYPE �������ͣ����磺int,double,CATUnicodeString ...
|
|
59
|
+
*/
|
|
60
|
+
#define SET_VALUE_BY_CkeParm(TYPE) \
|
|
61
|
+
if (checkExist) { \
|
|
62
|
+
TYPE old; \
|
|
63
|
+
HRESULT hr = GetSpecValue(name, old); \
|
|
64
|
+
if (FAILED(hr)) return hr; \
|
|
65
|
+
if (old == value) return S_OK; \
|
|
66
|
+
} \
|
|
67
|
+
CATICkeParm* ckeParm = get_CATICkeParm(name); \
|
|
68
|
+
if (NULL == ckeParm) return E_INVALIDARG; \
|
|
69
|
+
ckeParm->Valuate(value); \
|
|
70
|
+
KTCRelease(ckeParm)
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @brief ͨ��CATISpecAttrKey �趨ֵ
|
|
74
|
+
* @param TYPE ���������磺String��Double��IntBoolean
|
|
75
|
+
*/
|
|
76
|
+
#define SET_VALUE_BY_SpecAttrKey(TYPE) \
|
|
77
|
+
CATISpecAttrKey* attrKey = get_CATISpecAttrKey(name); \
|
|
78
|
+
if (NULL == attrKey) return E_INVALIDARG; \
|
|
79
|
+
HRESULT hr; \
|
|
80
|
+
if (checkExist && (attrAccess_->Get##TYPE(attrKey) == value)) \
|
|
81
|
+
hr = S_OK; \
|
|
82
|
+
else \
|
|
83
|
+
hr = attrAccess_->Set##TYPE(attrKey, value); \
|
|
84
|
+
attrKey->Release(); \
|
|
85
|
+
attrKey = NULL; \
|
|
86
|
+
return hr
|
|
87
|
+
|
|
88
|
+
//-----------------------------------------------------------------------------
|
|
89
|
+
KTCAutoAttrAccess::KTCAutoAttrAccess()
|
|
90
|
+
: attrAccess_(NULL) {
|
|
91
|
+
}
|
|
92
|
+
//-----------------------------------------------------------------------------
|
|
93
|
+
KTCAutoAttrAccess::~KTCAutoAttrAccess() {
|
|
94
|
+
attrAccess_ = NULL; // not release
|
|
95
|
+
}
|
|
96
|
+
//-----------------------------------------------------------------------------
|
|
97
|
+
KTCAutoAttrAccess::KTCAutoAttrAccess(const KTCAutoAttrAccess& iOriginal) {
|
|
98
|
+
*this = iOriginal;
|
|
99
|
+
}
|
|
100
|
+
//-----------------------------------------------------------------------------
|
|
101
|
+
KTCAutoAttrAccess& KTCAutoAttrAccess::operator=(const KTCAutoAttrAccess& iOriginal) {
|
|
102
|
+
return *this;
|
|
103
|
+
}
|
|
104
|
+
//-----------------------------------------------------------------------------
|
|
105
|
+
CATICkeInst_var KTCAutoAttrAccess::get_CATICkeInst(const char* name) const {
|
|
106
|
+
// get ckeParm (�ڲ�����������)
|
|
107
|
+
CATICkeParm* ckeParm = get_CATICkeParm(name);
|
|
108
|
+
if (NULL == ckeParm) return NULL_var;
|
|
109
|
+
|
|
110
|
+
// get ckeInst
|
|
111
|
+
CATICkeInst_var ckeInst = ckeParm->Value();
|
|
112
|
+
KTCRelease(ckeParm); // �ֶ��ͷ�
|
|
113
|
+
return ckeInst;
|
|
114
|
+
}
|
|
115
|
+
//-----------------------------------------------------------------------------
|
|
116
|
+
CATICkeParm* KTCAutoAttrAccess::get_CATICkeParm(const char* name) const {
|
|
117
|
+
// get attrkey (�ڲ�����������)
|
|
118
|
+
CATISpecAttrKey* attrKey = get_CATISpecAttrKey(name);
|
|
119
|
+
if (NULL == attrKey) return NULL;
|
|
120
|
+
|
|
121
|
+
// do no need check attrAccess_ here for get_CATISpecAttrKey already check
|
|
122
|
+
|
|
123
|
+
CATISpecObject* specObject = attrAccess_->GetSpecObject(attrKey);
|
|
124
|
+
KTCRelease(attrKey); // �ֶ��ͷ�
|
|
125
|
+
if (NULL == specObject) return NULL;
|
|
126
|
+
|
|
127
|
+
// get ckeParm
|
|
128
|
+
CATICkeParm* ckeParm = NULL;
|
|
129
|
+
specObject->QueryInterface(IID_CATICkeParm, (void**)&ckeParm);
|
|
130
|
+
return ckeParm;
|
|
131
|
+
}
|
|
132
|
+
//-----------------------------------------------------------------------------
|
|
133
|
+
CATISpecAttrKey* KTCAutoAttrAccess::get_CATISpecAttrKey(const char* name) const {
|
|
134
|
+
// ������
|
|
135
|
+
if (NULL == attrAccess_) return NULL; // check access
|
|
136
|
+
if (NULL == name) return NULL; // check check null
|
|
137
|
+
if (0 == *name) return NULL; // check empty
|
|
138
|
+
return attrAccess_->GetAttrKey(name);
|
|
139
|
+
}
|
|
140
|
+
//-----------------------------------------------------------------------------
|
|
141
|
+
HRESULT KTCAutoAttrAccess::GetListValue(const char* name,
|
|
142
|
+
CATListValCATBaseUnknown_var& value) const {
|
|
143
|
+
// ��� attrKey
|
|
144
|
+
CATISpecAttrKey* attrKey = get_CATISpecAttrKey(name);
|
|
145
|
+
if (NULL == attrKey) {
|
|
146
|
+
value.RemoveAll();
|
|
147
|
+
return E_INVALIDARG;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// ���δ֪�����б�
|
|
151
|
+
CATListValCATBaseUnknown_var* unknownList = ListSpecObjects(attrKey);
|
|
152
|
+
KTCRelease(attrKey); // �ֶ��ͷ�
|
|
153
|
+
if (NULL == unknownList) {
|
|
154
|
+
value.RemoveAll();
|
|
155
|
+
return E_FAIL;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
value = *unknownList; // ����
|
|
159
|
+
|
|
160
|
+
delete unknownList, unknownList = NULL; // �ֶ��ͷ�
|
|
161
|
+
return S_OK; // ��ȷ
|
|
162
|
+
}
|
|
163
|
+
//-----------------------------------------------------------------------------
|
|
164
|
+
HRESULT KTCAutoAttrAccess::GetListValue(const char* name,
|
|
165
|
+
CATListValCATISpecObject_var& value) const {
|
|
166
|
+
// ��� attrKey
|
|
167
|
+
CATISpecAttrKey* attrKey = get_CATISpecAttrKey(name);
|
|
168
|
+
if (NULL == attrKey) {
|
|
169
|
+
value.RemoveAll();
|
|
170
|
+
return E_INVALIDARG;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// ���δ֪�����б�
|
|
174
|
+
CATListValCATBaseUnknown_var* unknownList = ListSpecObjects(attrKey);
|
|
175
|
+
KTCRelease(attrKey); // �ֶ��ͷ�
|
|
176
|
+
if (NULL == unknownList) {
|
|
177
|
+
value.RemoveAll();
|
|
178
|
+
return E_FAIL;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// ����ռ䣬���
|
|
182
|
+
HRESULT hr = S_OK;
|
|
183
|
+
const int count = unknownList->Size(); // get size
|
|
184
|
+
value.Size(count, NULL); // �ı�ռ�
|
|
185
|
+
if (value.Size() != count) hr = E_OUTOFMEMORY;
|
|
186
|
+
|
|
187
|
+
// ����
|
|
188
|
+
if (SUCCEEDED(hr)) {
|
|
189
|
+
for (int i = 1; i <= count; i++) {
|
|
190
|
+
value[ i ] = (*unknownList)[ i ];
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
delete unknownList; // �ֶ��ͷ�, unknownList = NULL
|
|
195
|
+
return S_OK; // ��ȷ
|
|
196
|
+
}
|
|
197
|
+
//-----------------------------------------------------------------------------
|
|
198
|
+
HRESULT KTCAutoAttrAccess::GetSpecValue(const char* name, CATISpecObject_var& value) const {
|
|
199
|
+
GET_VALUE_FROM_SpecAttrKey(NULL_var, SpecObject);
|
|
200
|
+
return S_OK; // ��ȷ
|
|
201
|
+
}
|
|
202
|
+
//-----------------------------------------------------------------------------
|
|
203
|
+
HRESULT KTCAutoAttrAccess::GetSpecValue(const char* name, CATBoolean& value) const {
|
|
204
|
+
GET_CATICkeInst_DEFAULT(0); // ��� ckeInst
|
|
205
|
+
value = (int)ckeInst->AsBoolean(); // �õ�ֵ
|
|
206
|
+
return S_OK; // ��ȷ
|
|
207
|
+
}
|
|
208
|
+
//-----------------------------------------------------------------------------
|
|
209
|
+
HRESULT KTCAutoAttrAccess::GetSpecValue(const char* name, int& value) const {
|
|
210
|
+
GET_CATICkeInst_DEFAULT(0); // ��� ckeInst
|
|
211
|
+
value = ckeInst->AsInteger(); // �õ�ֵ
|
|
212
|
+
return S_OK; // ��ȷ
|
|
213
|
+
}
|
|
214
|
+
//-----------------------------------------------------------------------------
|
|
215
|
+
HRESULT KTCAutoAttrAccess::GetSpecValue(const char* name, double& value) const {
|
|
216
|
+
GET_CATICkeInst_DEFAULT(0.0); // ��� ckeInst
|
|
217
|
+
value = ckeInst->AsReal(); // �õ�ֵ
|
|
218
|
+
return S_OK; // ��ȷ
|
|
219
|
+
}
|
|
220
|
+
//-----------------------------------------------------------------------------
|
|
221
|
+
HRESULT KTCAutoAttrAccess::GetSpecValue(const char* name, CATUnicodeString& value) const {
|
|
222
|
+
GET_CATICkeInst_DEFAULT(""); // ��� ckeInst
|
|
223
|
+
value = ckeInst->AsString(); // �õ�ֵ
|
|
224
|
+
return S_OK; // ��ȷ
|
|
225
|
+
}
|
|
226
|
+
//-----------------------------------------------------------------------------
|
|
227
|
+
HRESULT KTCAutoAttrAccess::GetValue(const char* name, CATBoolean& value) const {
|
|
228
|
+
GET_CATISpecAttrKey_DEFAULT(0); // ��� attrKey
|
|
229
|
+
value = attrAccess_->GetBoolean(attrKey); // �õ�ֵ
|
|
230
|
+
KTCRelease(attrKey); // �ֶ��ͷ�
|
|
231
|
+
return S_OK; // ��ȷ
|
|
232
|
+
}
|
|
233
|
+
//-----------------------------------------------------------------------------
|
|
234
|
+
HRESULT KTCAutoAttrAccess::GetValue(const char* name, int& value) const {
|
|
235
|
+
GET_CATISpecAttrKey_DEFAULT(0); // ��� attrKey
|
|
236
|
+
value = attrAccess_->GetInteger(attrKey); // �õ�ֵ
|
|
237
|
+
KTCRelease(attrKey); // �ֶ��ͷ�
|
|
238
|
+
return S_OK; // ��ȷ
|
|
239
|
+
}
|
|
240
|
+
//-----------------------------------------------------------------------------
|
|
241
|
+
HRESULT KTCAutoAttrAccess::GetValue(const char* name, double& value) const {
|
|
242
|
+
GET_CATISpecAttrKey_DEFAULT(0.0); // ��� attrKey
|
|
243
|
+
value = attrAccess_->GetDouble(attrKey); // �õ�ֵ
|
|
244
|
+
KTCRelease(attrKey); // �ֶ��ͷ�
|
|
245
|
+
return S_OK; // ��ȷ
|
|
246
|
+
}
|
|
247
|
+
//-----------------------------------------------------------------------------
|
|
248
|
+
HRESULT KTCAutoAttrAccess::GetValue(const char* name, CATUnicodeString& value) const {
|
|
249
|
+
GET_CATISpecAttrKey_DEFAULT(""); // ��� attrKey
|
|
250
|
+
value = attrAccess_->GetString(attrKey); // �õ�ֵ
|
|
251
|
+
KTCRelease(attrKey); // �ֶ��ͷ�
|
|
252
|
+
return S_OK; // ��ȷ
|
|
253
|
+
}
|
|
254
|
+
//-----------------------------------------------------------------------------
|
|
255
|
+
HRESULT KTCAutoAttrAccess::GetValue(const char* name, KtString& value) const {
|
|
256
|
+
GET_CATISpecAttrKey_DEFAULT(""); // ��� attrKey
|
|
257
|
+
value = attrAccess_->GetString(attrKey).ConvertToChar(); // �õ�ֵ
|
|
258
|
+
KTCRelease(attrKey); // �ֶ��ͷ�
|
|
259
|
+
return S_OK; // ��ȷ
|
|
260
|
+
}
|
|
261
|
+
//-----------------------------------------------------------------------------
|
|
262
|
+
HRESULT KTCAutoAttrAccess::initial(CATBaseUnknown* baseUnkonwn) {
|
|
263
|
+
// clear and check input
|
|
264
|
+
attrAccess_ = NULL;
|
|
265
|
+
if (!baseUnkonwn) return E_POINTER;
|
|
266
|
+
|
|
267
|
+
// QueryInterface
|
|
268
|
+
return baseUnkonwn->QueryInterface(IID_CATISpecAttrAccess, (void**)&attrAccess_);
|
|
269
|
+
}
|
|
270
|
+
//----------------------------------------
|
|
271
|
+
CATListValCATBaseUnknown_var*
|
|
272
|
+
KTCAutoAttrAccess::ListSpecObjects(const CATISpecAttrKey* attrKey) const {
|
|
273
|
+
if (NULL == attrKey || NULL == attrAccess_) return NULL; // ���
|
|
274
|
+
return attrAccess_->ListSpecObjects(attrKey);
|
|
275
|
+
}
|
|
276
|
+
//-----------------------------------------------------------------------------
|
|
277
|
+
HRESULT KTCAutoAttrAccess::SetListValue(const char* name, const CATListValCATISpecObject_var& value,
|
|
278
|
+
CATBoolean checkExist) {
|
|
279
|
+
// ��� attrKey
|
|
280
|
+
CATISpecAttrKey* attrKey = get_CATISpecAttrKey(name);
|
|
281
|
+
if (NULL == attrKey) return E_INVALIDARG;
|
|
282
|
+
|
|
283
|
+
HRESULT hr = E_FAIL;
|
|
284
|
+
// check exist
|
|
285
|
+
if (checkExist) {
|
|
286
|
+
|
|
287
|
+
CATListValCATBaseUnknown_var* unknownList = attrAccess_->ListSpecObjects(attrKey);
|
|
288
|
+
|
|
289
|
+
if (unknownList && unknownList->Size() == value.Size()) {
|
|
290
|
+
// start from 1
|
|
291
|
+
for (int i = 1; i <= value.Size(); i++) {
|
|
292
|
+
if ((*unknownList)[ i ] != value[ i ]) {
|
|
293
|
+
// �Ƿ�����жϳ�һ�£��д�У�� ����� hr
|
|
294
|
+
attrAccess_->SetSpecObject(attrKey, value[ i ], i); // set no. i.
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
hr = S_OK;
|
|
298
|
+
}
|
|
299
|
+
delete unknownList; // �ֶ��ͷ�
|
|
300
|
+
if (SUCCEEDED(hr)) {
|
|
301
|
+
KTCRelease(attrKey); // �ֶ��ͷ�
|
|
302
|
+
return hr;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// ���ֵ
|
|
307
|
+
hr = attrAccess_->UnsetAttributeValue(attrKey);
|
|
308
|
+
if (FAILED(hr)) {
|
|
309
|
+
cout << " -[ERROR] when UnsetAttributeValue `" << name << endl;
|
|
310
|
+
// return hr;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
cout << " - add list value `" << name << "`: count =" << value.Size() << endl;
|
|
314
|
+
// ������� start from 1
|
|
315
|
+
for (int i = 1; i <= value.Size(); i++) {
|
|
316
|
+
// �Ƿ�����жϳ�һ�£��д�У�� ����� hr
|
|
317
|
+
hr = attrAccess_->SetSpecObject(attrKey, value[ i ], i); // set no. i.
|
|
318
|
+
cout << " - add No." << i << endl;
|
|
319
|
+
if (FAILED(hr)) {
|
|
320
|
+
cout << " -[ERROR] when SetSpecObject() for No. `" << i << endl;
|
|
321
|
+
// return hr;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
KTCRelease(attrKey); // �ֶ��ͷ�
|
|
326
|
+
return S_OK;
|
|
327
|
+
}
|
|
328
|
+
//-----------------------------------------------------------------------------
|
|
329
|
+
HRESULT KTCAutoAttrAccess::SetSpecValue(const char* name, CATISpecObject_var value,
|
|
330
|
+
CATBoolean checkExist) {
|
|
331
|
+
HRESULT hr;
|
|
332
|
+
// 1. ����ֵ����ֹ�������±��
|
|
333
|
+
if (checkExist) {
|
|
334
|
+
CATISpecObject_var old; // ��ֵ
|
|
335
|
+
hr = GetSpecValue(name, old); // ������ֵ
|
|
336
|
+
if (FAILED(hr)) return hr; // ��������
|
|
337
|
+
if (old == value) return S_OK; // ��ͬ
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// 2.���� CATISpecAttrKey
|
|
341
|
+
CATISpecAttrKey* attrKey = get_CATISpecAttrKey(name);
|
|
342
|
+
if (NULL == attrKey) return E_INVALIDARG;
|
|
343
|
+
|
|
344
|
+
// ������趨
|
|
345
|
+
if (NULL_var == value) { // ���ÿյ�ֵ
|
|
346
|
+
attrAccess_->UnsetAttributeValue(attrKey);
|
|
347
|
+
}
|
|
348
|
+
else { // ���÷ǿյ�ֵ
|
|
349
|
+
|
|
350
|
+
// ����Brep
|
|
351
|
+
CATIMfBRep_var bRep;
|
|
352
|
+
value->QueryInterface(IID_CATIMfBRep, (void**)&bRep); // ����鷵��ֵ
|
|
353
|
+
if (!!bRep) {
|
|
354
|
+
// ���BRep��˵��������
|
|
355
|
+
|
|
356
|
+
// ��ø��ף����д���
|
|
357
|
+
CATISpecObject_var father = value->GetFather();
|
|
358
|
+
if (NULL_var == father) {
|
|
359
|
+
// ���û�и��ף�Ҫ�ŵ���ǰ��attrAccess_��
|
|
360
|
+
// ������attrAccess_������hrֵ
|
|
361
|
+
CATIDescendants* descendants = NULL;
|
|
362
|
+
hr = attrAccess_->QueryInterface(IID_CATIDescendants, (void**)&descendants);
|
|
363
|
+
if (descendants) {
|
|
364
|
+
descendants->Append(value);
|
|
365
|
+
KTCRelease(descendants); // �ֶ��ͷ�
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
else {
|
|
369
|
+
hr = E_FAIL; // ���ײ��ܴ��ڣ�����
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// �������û�б������趨ֵ
|
|
374
|
+
if (SUCCEEDED(hr)) hr = attrAccess_->SetSpecObject(attrKey, value);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
KTCRelease(attrKey); // �ֶ��ͷ�
|
|
378
|
+
return hr;
|
|
379
|
+
}
|
|
380
|
+
//-----------------------------------------------------------------------------
|
|
381
|
+
HRESULT KTCAutoAttrAccess::SetSpecValue(const char* name, CATBoolean value, CATBoolean checkExist) {
|
|
382
|
+
SET_VALUE_BY_CkeParm(CATBoolean); // ͨ�����������趨ֵ
|
|
383
|
+
return S_OK;
|
|
384
|
+
}
|
|
385
|
+
//-----------------------------------------------------------------------------
|
|
386
|
+
HRESULT KTCAutoAttrAccess::SetSpecValue(const char* name, int value, CATBoolean checkExist) {
|
|
387
|
+
SET_VALUE_BY_CkeParm(int); // ͨ�����������趨ֵ
|
|
388
|
+
return S_OK;
|
|
389
|
+
}
|
|
390
|
+
//-----------------------------------------------------------------------------
|
|
391
|
+
HRESULT KTCAutoAttrAccess::SetSpecValue(const char* name, double value, CATBoolean checkExist) {
|
|
392
|
+
SET_VALUE_BY_CkeParm(double); // ͨ�����������趨ֵ
|
|
393
|
+
return S_OK;
|
|
394
|
+
}
|
|
395
|
+
//-----------------------------------------------------------------------------
|
|
396
|
+
HRESULT KTCAutoAttrAccess::SetSpecValue(const char* name, const CATUnicodeString& value,
|
|
397
|
+
CATBoolean checkExist) {
|
|
398
|
+
SET_VALUE_BY_CkeParm(CATUnicodeString); // ͨ�����������趨ֵ
|
|
399
|
+
return S_OK;
|
|
400
|
+
}
|
|
401
|
+
//-----------------------------------------------------------------------------
|
|
402
|
+
HRESULT KTCAutoAttrAccess::SetValue(const char* name, int value, CATBoolean checkExist) {
|
|
403
|
+
SET_VALUE_BY_SpecAttrKey(Integer); // �趨ֵ
|
|
404
|
+
}
|
|
405
|
+
//-----------------------------------------------------------------------------
|
|
406
|
+
HRESULT KTCAutoAttrAccess::SetValue(const char* name, double value, CATBoolean checkExist) {
|
|
407
|
+
SET_VALUE_BY_SpecAttrKey(Double); // �趨ֵ
|
|
408
|
+
}
|
|
409
|
+
//-----------------------------------------------------------------------------
|
|
410
|
+
HRESULT KTCAutoAttrAccess::SetValue(const char* name, CATBoolean value, CATBoolean checkExist) {
|
|
411
|
+
SET_VALUE_BY_SpecAttrKey(Boolean); // �趨ֵ
|
|
412
|
+
}
|
|
413
|
+
//-----------------------------------------------------------------------------
|
|
414
|
+
HRESULT KTCAutoAttrAccess::SetValue(const char* name, const CATUnicodeString& value,
|
|
415
|
+
CATBoolean checkExist) {
|
|
416
|
+
SET_VALUE_BY_SpecAttrKey(String); // �趨ֵ
|
|
417
|
+
}
|
|
418
|
+
//-----------------------------------------------------------------------------
|
|
419
|
+
HRESULT KTCAutoAttrAccess::SetValue(const char* name, const KtString& iValue,
|
|
420
|
+
CATBoolean checkExist) {
|
|
421
|
+
CATUnicodeString value = iValue.str();
|
|
422
|
+
SET_VALUE_BY_SpecAttrKey(String); // �趨ֵ
|
|
423
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Shanghai Kuntai Software Technology Co., Ltd. 2025
|
|
3
|
+
* @license MIT
|
|
4
|
+
* @author Phoenix Wing
|
|
5
|
+
* @checkout KTCAutoCode
|
|
6
|
+
* @file KTCAutoBuildGSM.cpp
|
|
7
|
+
* @brief
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#include "CATDocument.h"
|
|
11
|
+
#include "CATGeoFactory.h"
|
|
12
|
+
#include "CATGeometry.h"
|
|
13
|
+
#include "CATICGMObject.h"
|
|
14
|
+
#include "CATIContainer.h"
|
|
15
|
+
#include "CATIContainerOfDocument.h"
|
|
16
|
+
#include "CATIGeometricalElement.h" // Needed for DeleteScope and GetBodyResult
|
|
17
|
+
#include "CATILinkableObject.h"
|
|
18
|
+
#include "iostream.h"
|
|
19
|
+
|
|
20
|
+
// Local
|
|
21
|
+
#include "KTCAutoBuildGSM.h"
|
|
22
|
+
|
|
23
|
+
// auto code
|
|
24
|
+
#include "KTCAutoBody.h"
|
|
25
|
+
#include "KTCAutoDefine.h"
|
|
26
|
+
#include "KTCAutoErrors.h"
|
|
27
|
+
#include "KTCAutoPartDoc.h"
|
|
28
|
+
|
|
29
|
+
//-----------------------------------------------------------------------------
|
|
30
|
+
KTCAutoBuildGSM::KTCAutoBuildGSM()
|
|
31
|
+
: updateError(NULL)
|
|
32
|
+
, geometricalElement(NULL)
|
|
33
|
+
, procReport(NULL)
|
|
34
|
+
, geomFactory(NULL)
|
|
35
|
+
, softConfig(NULL) {
|
|
36
|
+
|
|
37
|
+
// your code here:
|
|
38
|
+
}
|
|
39
|
+
//-----------------------------------------------------------------------------
|
|
40
|
+
KTCAutoBuildGSM::~KTCAutoBuildGSM() {
|
|
41
|
+
|
|
42
|
+
KTCRelease(geometricalElement); // �ֶ��ͷ�
|
|
43
|
+
KTCRelease(updateError); // �ֶ��ͷ�
|
|
44
|
+
KTCRelease(procReport); // �ֶ��ͷ� the procedural report
|
|
45
|
+
KTCRelease(softConfig); // �ֶ��ͷ� the software configuration
|
|
46
|
+
KTCRelease(geomFactory); // �ֶ��ͷ�
|
|
47
|
+
}
|
|
48
|
+
//-----------------------------------------------------------------------------
|
|
49
|
+
KTCAutoBuildGSM::KTCAutoBuildGSM(const KTCAutoBuildGSM& iOriginal) {
|
|
50
|
+
}
|
|
51
|
+
//-----------------------------------------------------------------------------
|
|
52
|
+
KTCAutoBuildGSM& KTCAutoBuildGSM::operator=(const KTCAutoBuildGSM& iOriginal) {
|
|
53
|
+
return *this;
|
|
54
|
+
}
|
|
55
|
+
//-----------------------------------------------------------------------------
|
|
56
|
+
HRESULT KTCAutoBuildGSM::query_factory(CATISpecObject_var object) {
|
|
57
|
+
KTCRelease(geomFactory); // �ֶ��ͷ� �ɵ�
|
|
58
|
+
if (NULL_var == object) return S_OK;
|
|
59
|
+
|
|
60
|
+
// Gets a pointer on CATISpecObject.
|
|
61
|
+
CATILinkableObject* linkObject = NULL;
|
|
62
|
+
HRESULT rc = object->QueryInterface(IID_CATILinkableObject, (void**)&linkObject);
|
|
63
|
+
if (SUCCEEDED(rc)) {
|
|
64
|
+
// Do not release this pointer
|
|
65
|
+
CATDocument* pDocument = NULL;
|
|
66
|
+
pDocument = linkObject->GetDocument();
|
|
67
|
+
|
|
68
|
+
if (NULL != pDocument) {
|
|
69
|
+
CATIContainerOfDocument* pIContainerOfDocument = NULL;
|
|
70
|
+
rc = pDocument->QueryInterface(IID_CATIContainerOfDocument,
|
|
71
|
+
(void**)&pIContainerOfDocument);
|
|
72
|
+
if (SUCCEEDED(rc)) {
|
|
73
|
+
CATIContainer* container = NULL;
|
|
74
|
+
rc = pIContainerOfDocument->GetResultContainer(container);
|
|
75
|
+
if (SUCCEEDED(rc)) {
|
|
76
|
+
rc = container->QueryInterface(IID_CATGeoFactory, (void**)&geomFactory);
|
|
77
|
+
KTCRelease(container); // �ֶ��ͷ�
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
KTCRelease(pIContainerOfDocument); // �ֶ��ͷ�
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
pDocument = NULL; // �����ͷ�
|
|
84
|
+
KTCRelease(linkObject); // �ֶ��ͷ�
|
|
85
|
+
}
|
|
86
|
+
return rc;
|
|
87
|
+
}
|
|
88
|
+
//-----------------------------------------------------------------------------
|
|
89
|
+
HRESULT KTCAutoBuildGSM::remove(CATBody*& body) {
|
|
90
|
+
if (NULL == body) return S_OK;
|
|
91
|
+
|
|
92
|
+
if (geomFactory) {
|
|
93
|
+
// Removes the intermediate CATBody
|
|
94
|
+
|
|
95
|
+
// TODO : error C2664: ��void CATICGMContainer::Remove(CATICGMObject *,const
|
|
96
|
+
// CATICGMContainer::CATRemovingDependancies)��: ���ܽ����� 1 �ӡ�CATBody
|
|
97
|
+
// *��ת��Ϊ��CATICGMObject *��
|
|
98
|
+
cout << " û��ʵ��" << __FUNCTION__ << endl;
|
|
99
|
+
return E_INVALIDARG;
|
|
100
|
+
// geomFactory->Remove(body);
|
|
101
|
+
body = NULL;
|
|
102
|
+
return S_OK;
|
|
103
|
+
}
|
|
104
|
+
return E_INVALIDARG;
|
|
105
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Shanghai Kuntai Software Technology Co., Ltd. 2025
|
|
3
|
+
* @license MIT
|
|
4
|
+
* @author Phoenix Wing
|
|
5
|
+
* @checkout KTCAutoCode
|
|
6
|
+
* @file KTCAutoPartDoc.cpp
|
|
7
|
+
* @version V1.0
|
|
8
|
+
* @date 2025-12-17
|
|
9
|
+
* @brief
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
// cat
|
|
13
|
+
#include "CATFrmEditor.h"
|
|
14
|
+
#include "CATIBuildPath.h"
|
|
15
|
+
#include "CATIGSMTool.h"
|
|
16
|
+
#include "CATIMmiNonOrderedGeometricalSet.h"
|
|
17
|
+
#include "CATIPrtPart.h"
|
|
18
|
+
#include "CATPathElement.h"
|
|
19
|
+
|
|
20
|
+
// auto code
|
|
21
|
+
#include "KTCAutoDefine.h"
|
|
22
|
+
#include "KTCAutoGSM.h"
|
|
23
|
+
#include "KTCAutoPartDoc.h"
|
|
24
|
+
|
|
25
|
+
//-----------------------------------------------------------------------------
|
|
26
|
+
KTCAutoPartDoc::KTCAutoPartDoc()
|
|
27
|
+
: catFrmEditor_(NULL)
|
|
28
|
+
, gsmTool_(NULL) {
|
|
29
|
+
|
|
30
|
+
// your code here:
|
|
31
|
+
}
|
|
32
|
+
//-----------------------------------------------------------------------------
|
|
33
|
+
KTCAutoPartDoc::~KTCAutoPartDoc() {
|
|
34
|
+
catFrmEditor_ = NULL; // �����ͷ�
|
|
35
|
+
KTCRelease(gsmTool_); // �ֶ��ͷ�
|
|
36
|
+
}
|
|
37
|
+
//-----------------------------------------------------------------------------
|
|
38
|
+
KTCAutoPartDoc::KTCAutoPartDoc(const KTCAutoPartDoc& iOriginal) {
|
|
39
|
+
}
|
|
40
|
+
//-----------------------------------------------------------------------------
|
|
41
|
+
KTCAutoPartDoc& KTCAutoPartDoc::operator=(const KTCAutoPartDoc& iOriginal) {
|
|
42
|
+
return *this;
|
|
43
|
+
}
|
|
44
|
+
//-----------------------------------------------------------------------------
|
|
45
|
+
HRESULT KTCAutoPartDoc::checkout_pathelement(CATISpecObject_var object,
|
|
46
|
+
CATPathElement** pathElement) {
|
|
47
|
+
|
|
48
|
+
// check path element
|
|
49
|
+
if (!pathElement) return E_INVALIDARG;
|
|
50
|
+
*pathElement = NULL; // initialize
|
|
51
|
+
|
|
52
|
+
// check object
|
|
53
|
+
if (!object) return E_INVALIDARG;
|
|
54
|
+
|
|
55
|
+
// parameters
|
|
56
|
+
CATIBuildPath* buildPath = NULL;
|
|
57
|
+
HRESULT hr;
|
|
58
|
+
|
|
59
|
+
// check editor
|
|
60
|
+
if (!catFrmEditor_) {
|
|
61
|
+
hr = initial_editor(NULL);
|
|
62
|
+
if (FAILED(hr)) return hr;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// checkout build path
|
|
66
|
+
hr = object->QueryInterface(IID_CATIBuildPath, (void**)&buildPath);
|
|
67
|
+
if (FAILED(hr)) return hr;
|
|
68
|
+
|
|
69
|
+
// check out path element
|
|
70
|
+
CATPathElement context = catFrmEditor_->GetUIActiveObject();
|
|
71
|
+
hr = buildPath->ExtractPathElement(&context, pathElement);
|
|
72
|
+
KTCRelease(buildPath);
|
|
73
|
+
return hr;
|
|
74
|
+
}
|
|
75
|
+
//-----------------------------------------------------------------------------
|
|
76
|
+
HRESULT KTCAutoPartDoc::checkout_pathelement(const CATListValCATISpecObject_var& iList,
|
|
77
|
+
CATLISTP(CATPathElement) & oList) {
|
|
78
|
+
oList.RemoveAll(); // initialize
|
|
79
|
+
|
|
80
|
+
if (0 == iList.Size()) return S_OK;
|
|
81
|
+
|
|
82
|
+
// parameters
|
|
83
|
+
CATPathElement* pathElement = NULL;
|
|
84
|
+
HRESULT hr;
|
|
85
|
+
|
|
86
|
+
// checkout path element list from index 1
|
|
87
|
+
for (int i = 1; i <= iList.Size(); i++) {
|
|
88
|
+
hr = this->checkout_pathelement(iList[ i ], &pathElement);
|
|
89
|
+
if (FAILED(hr)) return hr; // error
|
|
90
|
+
oList.Append(pathElement);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return S_OK; // ok
|
|
94
|
+
}
|
|
95
|
+
//-----------------------------------------------------------------------------
|
|
96
|
+
HRESULT KTCAutoPartDoc::initial_editor(CATFrmEditor* iEditor) {
|
|
97
|
+
// 1. set to input editor
|
|
98
|
+
if (iEditor) {
|
|
99
|
+
catFrmEditor_ = iEditor;
|
|
100
|
+
return S_OK;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// 2.already initialized
|
|
104
|
+
if (catFrmEditor_) return S_OK;
|
|
105
|
+
|
|
106
|
+
// 3. check and get current editor
|
|
107
|
+
catFrmEditor_ = CATFrmEditor::GetCurrentEditor();
|
|
108
|
+
if (!catFrmEditor_) return E_POINTER; // failed
|
|
109
|
+
|
|
110
|
+
return S_OK; // ok
|
|
111
|
+
}
|
|
112
|
+
//-----------------------------------------------------------------------------
|
|
113
|
+
HRESULT KTCAutoPartDoc::initial_GSMTool_From_GeomSet() {
|
|
114
|
+
if (gsmTool_) return S_OK;
|
|
115
|
+
|
|
116
|
+
return KTCAutoGSM::LookingForGeomSet(catFrmEditor_, &gsmTool_);
|
|
117
|
+
}
|
|
118
|
+
//-----------------------------------------------------------------------------
|
|
119
|
+
HRESULT KTCAutoPartDoc::QueryInterface(const IID& iIID, void** oPPV) {
|
|
120
|
+
return KTCAutoGSM::QueryInterface(gsmTool_, iIID, oPPV);
|
|
121
|
+
}
|