www.pudn.com > SurfWareNew06.3.5(LYW).rar > EditSurfaceTrim.cpp
// EditSurfaceTrim.cpp : implementation file
//
#include "stdafx.h"
#include "surfware.h"
#include "EditSurfaceTrim.h"
#include "Nurbs_Lib/NURBS_PointND.h"
#include "Nurbs_Lib/NURBS_HPointND.h"
#include "HPoint.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// EditSurfaceTrim dialog
EditSurfaceTrim::EditSurfaceTrim(CSurfWareDoc *pDoc,CWnd* pParent /*=NULL*/)
: CDialog(EditSurfaceTrim::IDD, pParent)
{
//{{AFX_DATA_INIT(EditSurfaceTrim)
m_fPercentL = 0.0f;
m_fPercentR = 0.0f;
m_pDoc=pDoc;
m_dir=1;
//}}AFX_DATA_INIT
}
void EditSurfaceTrim::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(EditSurfaceTrim)
DDX_Control(pDX, IDC_SLD2, m_sldPrecentR);
DDX_Control(pDX, IDC_SLD1, m_sldPrecentL);
DDX_Control(pDX, IDC_PERCENT2, m_edPercentR);
DDX_Control(pDX, IDC_PERCENT1, m_edPercentL);
DDX_Text(pDX, IDC_PERCENT1, m_fPercentL);
DDX_Text(pDX, IDC_PERCENT2, m_fPercentR);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(EditSurfaceTrim, CDialog)
//{{AFX_MSG_MAP(EditSurfaceTrim)
ON_NOTIFY(NM_CUSTOMDRAW, IDC_SLD1, OnCustomdrawSld1)
ON_WM_DESTROY()
ON_EN_CHANGE(IDC_PERCENT1, OnChangePercent1)
ON_NOTIFY(NM_CUSTOMDRAW, IDC_SLD2, OnCustomdrawSld2)
ON_EN_CHANGE(IDC_PERCENT2, OnChangePercent2)
ON_BN_CLICKED(IDC_U, OnU)
ON_BN_CLICKED(IDC_V, OnV)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// EditSurfaceTrim message handlers
void EditSurfaceTrim::OnCustomdrawSld1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
m_fPercentL=(float)m_sldPrecentL.GetPos()/100.;
CString str;
str.Format("%.2f",m_fPercentL);
m_edPercentL.SetWindowText(str);
UpdateViews();
*pResult = 0;
}
void EditSurfaceTrim::UpdateViews()
{
CSurfNurbsSurface* sf=m_pDoc->m_CurrentSelSurface.GetHead();
m_pDoc->m_TempCurve.GetElement(0)->NURBS_ExtractCurve(*sf,m_fPercentL/100.,m_dir);
m_pDoc->m_TempCurve.GetElement(1)->NURBS_ExtractCurve(*sf,m_fPercentR/100.,m_dir);
m_pDoc->UpdateAllViews(NULL);
}
void EditSurfaceTrim::OnDestroy()
{
CDialog::OnDestroy();
// TODO: Add your message handler code here
m_pDoc->m_FitPtContainer.Reset();
}
BOOL EditSurfaceTrim::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_sldPrecentL.SetRange(0,10000);
m_sldPrecentR.SetRange(0,10000);
for(int i=999;i<9999;i+=1000)
m_sldPrecentL.SetTic(i);
m_sldPrecentR.SetRange(0,10000);
for(int j=999;j<9999;j+=1000)
m_sldPrecentR.SetTic(j);
CSurfNurbsCurve* tempCVL=new CSurfNurbsCurve;
CSurfNurbsCurve* tempCVR=new CSurfNurbsCurve;
tempCVL->SetColor(RGB(255,0,0));
m_pDoc->m_TempCurve.AddTail(tempCVL);
tempCVR->SetColor(RGB(255,0,0));
m_pDoc->m_TempCurve.AddTail(tempCVR);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void EditSurfaceTrim::OnChangePercent1()
{
UpdateData(TRUE);
m_sldPrecentL.SetPos(m_fPercentL*100);
}
void EditSurfaceTrim::OnCustomdrawSld2(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
m_fPercentR=(float)m_sldPrecentR.GetPos()/100.;
CString str;
str.Format("%.2f",m_fPercentR);
m_edPercentR.SetWindowText(str);
UpdateViews();
*pResult = 0;
}
void EditSurfaceTrim::OnChangePercent2()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_sldPrecentR.SetPos(m_fPercentR*100);
}
void EditSurfaceTrim::OnU()
{
// TODO: Add your control notification handler code here
m_dir=1;
}
void EditSurfaceTrim::OnV()
{
// TODO: Add your control notification handler code here
m_dir=2;
}