📄 createcyldialog.cpp
字号:
ar >> m_VerticalStripes;
ar >> m_YSize;
}
}
void CCreateCylDialog::OnDefaults()
{
m_BotXOffset = 0.0;
m_BotXSize = 128.0;
m_BotZOffset = 0.0;
m_BotZSize = 128.0;
m_Solid = 1;
m_Thickness = 16.0;
m_TopXOffset = 0.0;
m_TopXSize = 128.0;
m_TopZOffset = 0.0;
m_TopZSize = 128.0;
m_VerticalStripes = 8;
m_YSize = 512.0;
m_RingLength = 3.0;
m_TCut = FALSE;
UpdateData(FALSE);
OnOK();
}
/* EOF: CreateCylDialog.cpp */
void CCreateCylDialog::OnOK()
{
UpdateData(TRUE);
if(m_ConvertToMetric)
{
dlgFieldsToTexels();
}
if (!m_customTemplate) // if the Custom Template button is NOT pushed
{
if (m_pDoc->CurBrush)
{
pCyl = m_pDoc->CurBrush;
}
}
else if (m_customTemplate) // if the Custom Template button is pushed
{
m_pCylTemplate->BotXOffset = m_BotXOffset;
m_pCylTemplate->BotXSize = m_BotXSize;
m_pCylTemplate->BotZOffset = m_BotZOffset;
m_pCylTemplate->BotZSize = m_BotZSize;
m_pCylTemplate->Solid = m_Solid;
m_pCylTemplate->Thickness = m_Thickness;
m_pCylTemplate->TopXOffset = m_TopXOffset;
m_pCylTemplate->TopXSize = m_TopXSize;
m_pCylTemplate->TopZOffset = m_TopZOffset;
m_pCylTemplate->TopZSize = m_TopZSize;
m_pCylTemplate->VerticalStripes = m_VerticalStripes;
m_pCylTemplate->YSize = m_YSize;
m_pCylTemplate->RingLength = m_RingLength;
m_pCylTemplate->TCut = m_TCut;
pCyl = BrushTemplate_CreateCylinder (m_pCylTemplate);
if (pCyl != NULL)
{
m_pDoc->CreateNewTemplateBrush ((Brush*)pCyl);
m_pDoc->m_recentCyl = Brush_Clone(pCyl); // post 0.55
Brush_SetName(m_pDoc->CurBrush, "Cylinder"); // post 0.55
}
}
}
void CCreateCylDialog::OnCustomizeCylBtn()
{
static bool toggle;
toggle = !m_customTemplate;
m_customTemplate = toggle;
m_pDoc->mpMainFrame->UpdateMainControls();
}
void CCreateCylDialog::OnApplyCylBtn()
{
OnOK();
m_pDoc->AddBrushToWorld();
m_pDoc->mpMainFrame->UpdateMainControls();
}
void CCreateCylDialog::OnKillfocusTopxsize()
{
float lastValue = m_TopXSize;
if (GetDlgItemInt(IDC_TOPXSIZE) == NULL)
{
this->SetDlgItemInt(IDC_TOPXSIZE, lastValue);
return;
}
UpdateData(TRUE);
if ((m_TopXSize >= BRUSH_MIN) && (m_TopXSize <= BRUSH_MAX))
OnOK();
else
{
m_TopXSize = lastValue;
UpdateData(FALSE);
AfxMessageBox(m_minMaxErrorString);
}
}
void CCreateCylDialog::OnKillfocusTopxoff()
{
float lastValue = m_TopXOffset;
if (GetDlgItemInt(IDC_TOPXOFF) == NULL)
{
this->SetDlgItemInt(IDC_TOPXOFF, lastValue);
return;
}
UpdateData(TRUE);
if ((m_TopXOffset >= 0) && (m_TopXOffset <= BRUSH_MAX))
OnOK();
else
{
m_TopXOffset = lastValue;
UpdateData(FALSE);
AfxMessageBox(m_minMaxErrorString);
}
}
void CCreateCylDialog::OnKillfocusTopzsize()
{
float lastValue = m_TopZSize;
if (GetDlgItemInt(IDC_TOPZSIZE) == NULL)
{
this->SetDlgItemInt(IDC_TOPZSIZE, lastValue);
return;
}
UpdateData(TRUE);
if ((m_TopZSize >= BRUSH_MIN) && (m_TopZSize <= BRUSH_MAX))
OnOK();
else
{
m_TopZSize = lastValue;
UpdateData(FALSE);
AfxMessageBox(m_minMaxErrorString);
}
}
void CCreateCylDialog::OnKillfocusTopzoff()
{
float lastValue = m_TopZOffset;
if (GetDlgItemInt(IDC_TOPZOFF) == NULL)
{
this->SetDlgItemInt(IDC_TOPZOFF, lastValue);
return;
}
UpdateData(TRUE);
if ((m_TopZOffset >= 0) && (m_TopZOffset <= BRUSH_MAX))
OnOK();
else
{
m_TopZOffset = lastValue;
UpdateData(FALSE);
AfxMessageBox(m_minMaxErrorString);
}
}
void CCreateCylDialog::OnKillfocusBotxsize()
{
float lastValue = m_BotXSize;
if (GetDlgItemInt(IDC_BOTXSIZE) == NULL)
{
this->SetDlgItemInt(IDC_BOTXSIZE, lastValue);
return;
}
UpdateData(TRUE);
if ((m_BotXSize >= BRUSH_MIN) && (m_BotXSize <= BRUSH_MAX))
OnOK();
else
{
m_BotXSize = lastValue;
UpdateData(FALSE);
AfxMessageBox(m_minMaxErrorString);
}
}
void CCreateCylDialog::OnKillfocusBotxoff()
{
float lastValue = m_BotXOffset;
if (GetDlgItemInt(IDC_BOTXOFF) == NULL)
{
this->SetDlgItemInt(IDC_BOTXOFF, lastValue);
return;
}
UpdateData(TRUE);
if ((m_BotXOffset >= 0) && (m_BotXOffset <= BRUSH_MAX))
OnOK();
else
{
m_BotXOffset = lastValue;
UpdateData(FALSE);
AfxMessageBox(m_minMaxErrorString);
}
}
void CCreateCylDialog::OnKillfocusBotzsize()
{
float lastValue = m_BotZSize;
if (GetDlgItemInt(IDC_BOTZSIZE) == NULL)
{
this->SetDlgItemInt(IDC_BOTZSIZE, lastValue);
return;
}
UpdateData(TRUE);
if ((m_BotZSize >= BRUSH_MIN) && (m_BotZSize <= BRUSH_MAX))
OnOK();
else
{
m_BotZSize = lastValue;
UpdateData(FALSE);
AfxMessageBox(m_minMaxErrorString);
}
}
void CCreateCylDialog::OnKillfocusBotzoff()
{
float lastValue = m_BotZOffset;
if (GetDlgItemInt(IDC_BOTZOFF) == NULL)
{
this->SetDlgItemInt(IDC_BOTZOFF, lastValue);
return;
}
UpdateData(TRUE);
if ((m_BotZOffset >= 0) && (m_BotZOffset <= BRUSH_MAX))
OnOK();
else
{
m_BotZOffset = lastValue;
UpdateData(FALSE);
AfxMessageBox(m_minMaxErrorString);
}
}
void CCreateCylDialog::OnKillfocusYsize()
{
float lastValue = m_YSize;
if (GetDlgItemInt(IDC_YSIZE) == NULL)
{
this->SetDlgItemInt(IDC_YSIZE, lastValue);
return;
}
UpdateData(TRUE);
if ((m_YSize >= BRUSH_MIN) && (m_YSize <= BRUSH_MAX))
OnOK();
else
{
m_YSize = lastValue;
UpdateData(FALSE);
AfxMessageBox(m_minMaxErrorString);
}
}
void CCreateCylDialog::OnKillfocusVertstripes()
{
int lastValue = m_VerticalStripes;
if (GetDlgItemInt(IDC_VERTSTRIPES) == NULL)
{
this->SetDlgItemInt(IDC_VERTSTRIPES, lastValue);
return;
}
UpdateData(TRUE);
if ((m_VerticalStripes >= 5) && (m_VerticalStripes <= 64))
OnOK();
else
{
m_VerticalStripes = lastValue;
UpdateData(FALSE);
AfxMessageBox("Value must be >= 5 and <= 64");
}
}
void CCreateCylDialog::OnKillfocusThickness()
{
float lastValue = m_Thickness;
if (GetDlgItemInt(IDC_THICKNESS) == NULL)
{
this->SetDlgItemInt(IDC_THICKNESS, lastValue);
return;
}
UpdateData(TRUE);
if ((m_Thickness >= WALL_THICK_MIN) && (m_Thickness <= WALL_THICK_MAX))
OnOK();
else
{
m_Thickness = lastValue;
UpdateData(FALSE);
AfxMessageBox(m_wallThicknessErrorString);
}
}
void CCreateCylDialog::OnKillfocusRinglength()
{
float lastValue = m_RingLength;
if (GetDlgItemInt(IDC_RINGLENGTH) == NULL)
{
this->SetDlgItemInt(IDC_RINGLENGTH, lastValue);
return;
}
UpdateData(TRUE);
if ((m_RingLength >= BRUSH_MIN) && (m_RingLength <= BRUSH_MAX))
OnOK();
else
{
m_RingLength = lastValue;
UpdateData(FALSE);
AfxMessageBox(m_minMaxErrorString);
}
}
void CCreateCylDialog::OnSolid()
{
OnOK();
}
void CCreateCylDialog::OnHollow()
{
OnOK();
}
void CCreateCylDialog::OnRing()
{
OnOK();
}
void CCreateCylDialog::OnTcut()
{
OnOK();
}
void CCreateCylDialog::OnCancel()
{
return;
}
BOOL CCreateCylDialog::OnInitDialog()
{
CDialog::OnInitDialog();
this->GetDlgItem(IDC_CUSTOMIZE_CYL_BTN)->SetFocus();
return FALSE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -