-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiogIgsImportDlg.cpp
233 lines (192 loc) · 6.17 KB
/
iogIgsImportDlg.cpp
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
//=============================================================================
//
// Copyright (c) China Automotive Innovation Corporation.
//
// Author : Xia Lei
// Date : 2022/09/14
//
//=============================================================================
#include "iogIgsImportDlg.h"
#include "ui_iogIgsImportDlg.h"
#define Igs_Import_MaxHoleArea "iog_param/parameter/import_igs/holearea"
#define Igs_Import_MaxFilletRad "iog_param/parameter/import_igs/filletrad"
#define Igs_Import_Unit "iog_param/parameter/import_igs/unit"
#define Igs_Import_UnitType "iog_param/parameter/import_igs/unittype"
#define Igs_Import_DiscreType "iog_param/parameter/import_igs/discretype"
#define Igs_Import_DiscreLinear "iog_param/parameter/import_igs/discretlinear"
#define Igs_Import_DiscreAngle "iog_param/parameter/import_igs/discretangle"
#define Igs_Import_SewingTolerance "iog_param/parameter/import_igs/sewingtolerance"
///////////////////////////////////////////////////////////////////////////////
//
iogIgsImportDlg::iogIgsImportDlg(QPopDialog *parent) : QPopDialog(parent)
{
ui = new Ui::iogIgsImportDlg();
ui->setupUi(this);
this->InitIgsDlg();
connect(ui->cmbDiscre, SIGNAL(currentIndexChanged(int)), this, SLOT(ChangeIdx()));
connect(ui->btnOk, SIGNAL(clicked()), this, SLOT(OnOk()));
connect(ui->btnCancel, SIGNAL(clicked()), this, SLOT(OnCancel()));
}
iogIgsImportDlg::~iogIgsImportDlg()
{
delete ui;
}
///////////////////////////////////////////////////////////////////////////////
//
void iogIgsImportDlg::InitIgsDlg()
{
this->SetTips();
this->SetValid();
int nLengthSubs = ConfigGetSubUnitSize(0);
for (int i = 0; i < nLengthSubs; ++i)
{
const char * pLengthName = ConfigGetUnitSubName(0, i);
QString strLengthName(pLengthName);
ui->cmbUnits->addItem(strLengthName);
}
int nCurLength = ConfigGetUnitCurrentValue(0);//
ui->cmbUnits->setCurrentIndex(0);
ui->cmbDiscre->addItem("Extreme Rough");
ui->cmbDiscre->addItem("Rough");
ui->cmbDiscre->addItem("Medium");
ui->cmbDiscre->addItem("Fine");
ui->cmbDiscre->addItem("Extreme Fine");
ui->cmbDiscre->setCurrentIndex(2);
ui->LinearDelVal->setText("0.004");
ui->AngleDelVal->setText("0.22");
ui->sewTol->setText("0.1");
this->ReadXMLStlPara();
}
void iogIgsImportDlg::ChangeIdx()
{
if (ui->cmbDiscre->currentIndex() == 0)
{
ui->LinearDelVal->setText("0.016");
ui->AngleDelVal->setText("0.88");
//ui->LinearDelVal->setDisabled(true);
//ui->AngleDelVal->setDisabled(true);
}
else if (ui->cmbDiscre->currentIndex() == 1)
{
ui->LinearDelVal->setText("0.008");
ui->AngleDelVal->setText("0.44");
//ui->LinearDelVal->setDisabled(true);
//ui->AngleDelVal->setDisabled(true);
}
else if (ui->cmbDiscre->currentIndex() == 2)
{
ui->LinearDelVal->setText("0.004");
ui->AngleDelVal->setText("0.22");
//ui->LinearDelVal->setDisabled(true);
//ui->AngleDelVal->setDisabled(true);
}
else if (ui->cmbDiscre->currentIndex() == 3)
{
ui->LinearDelVal->setText("0.002");
ui->AngleDelVal->setText("0.11");
//ui->LinearDelVal->setDisabled(true);
//ui->AngleDelVal->setDisabled(true);
}
else if (ui->cmbDiscre->currentIndex() == 4)
{
ui->LinearDelVal->setText("0.001");
ui->AngleDelVal->setText("0.06");
//ui->LinearDelVal->setDisabled(true);
//ui->AngleDelVal->setDisabled(true);
}
}
void iogIgsImportDlg::ReadXMLStlPara()
{
GetXmlValueD(Igs_Import_MaxHoleArea, m_dHoleRad);
if (m_dHoleRad == 0)
{
ui->holeArea->setText("0.0");
}
else
ui->holeArea->setText(QString::number(m_dHoleRad, 'f', 6));
}
bool iogIgsImportDlg::IsEffect()
{
QString strTol = ui->holeArea->text();
bool bTrans = false;
double dTol = strTol.toDouble(&bTrans);
m_dHoleRad = dTol;
QString strLinearDelVal = ui->LinearDelVal->text();
m_dLinearDelVal = strLinearDelVal.toDouble(&bTrans);
QString strAngleDelVal = ui->AngleDelVal->text();
m_dAngleDelVal = strAngleDelVal.toDouble(&bTrans);
QString strSewVal = ui->sewTol->text();
m_dSewVal = strSewVal.toDouble(&bTrans);
int nUnitSelIndex = ui->cmbUnits->currentIndex();
m_nUnitType = nUnitSelIndex;
int nCurLength = ConfigGetUnitCurrentValue(0);
if (nUnitSelIndex == nCurLength)
{
m_dLenTransFac = 1;
}
double dCurMeter = ConfigGetUnitFactor(0, nCurLength);//current unit to meter
double dSelMeter = ConfigGetUnitFactor(0, nUnitSelIndex);//select unit to meter
m_dLenTransFac = dSelMeter / dCurMeter;
m_nDiscreType = ui->cmbDiscre->currentIndex();
return true;
}
void iogIgsImportDlg::SetTips()
{
QString strHoleTol = QObject::tr("Auto fill hole radius");
QString strFilletTol = QObject::tr("Maxium allowed auto remove Fillet radius");
QString strUnit = QObject::tr("Units");
QString strOk = QObject::tr("OK");
QString strCancel = QObject::tr("Cancel");
QString strGrid = QObject::tr("Quality of the grid");
//ui->filletTolerance->setToolTip(strFilletTol);
ui->holeTolerance->setToolTip(strHoleTol);
ui->labelUnits->setToolTip(strUnit);
ui->btnCancel->setToolTip(strCancel);
ui->btnOk->setToolTip(strOk);
ui->labelDiscre->setToolTip(strGrid);
}
void iogIgsImportDlg::SetValid()
{
QRegExp regExp1("^0?|(?!0\\d)\\d+(\\.\\d*)?((E|e)(\\+|\\-)?)?\\d{0,2}$");
ui->holeArea->setValidator(new QRegExpValidator(regExp1, this));
}
void iogIgsImportDlg::WriteXMLPara()
{
SetXmlValueD(Igs_Import_MaxFilletRad, m_dFilletRad);
SetXmlValueD(Igs_Import_MaxHoleArea, m_dHoleRad);
SetXmlValueD(Igs_Import_Unit, m_dLenTransFac);
SetXmlValueD(Igs_Import_DiscreLinear, m_dLinearDelVal);
SetXmlValueD(Igs_Import_DiscreAngle, m_dAngleDelVal);
SetXmlValueD(Igs_Import_SewingTolerance, m_dSewVal);
SetXmlValueN(Igs_Import_UnitType, m_nUnitType);
SetXmlValueN(Igs_Import_DiscreType, m_nDiscreType);
}
///////////////////////////////////////////////////////////////////////////////
//
void iogIgsImportDlg::OnOk()
{
bool bEffect = IsEffect();
if (bEffect)
{
this->WriteXMLPara();
QPopDialog::accept();
}
else
{
QString strMsg = QObject::tr("The file was imported failed for invalid parameter");
TheExe.PrintMessage(strMsg, apiExe::MSG_ERROR);
QPopDialog::reject();
}
}
void iogIgsImportDlg::OnCancel()
{
QPopDialog::reject();
}
double iogIgsImportDlg::GetAngleDelVal()
{
return m_dAngleDelVal;
}
double iogIgsImportDlg::GetLinearDelVal()
{
return m_dLinearDelVal;
}