📄 dlgloadsequence.cpp
字号:
// DlgLoadSequence.cpp : implementation file
//
#include "stdafx.h"
#include "SeqProcess.h"
#include "DlgLoadSequence.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgLoadSequence dialog
CDlgLoadSequence::CDlgLoadSequence(CWnd* pParent /*=NULL*/)
: CDialog(CDlgLoadSequence::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgLoadSequence)
m_from = 0;
m_message = _T("");
m_to = 0;
//}}AFX_DATA_INIT
m_start = 0;
m_end = 0;
m_verify = TRUE;
m_seqName = _T("");
}
void CDlgLoadSequence::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgLoadSequence)
DDX_Text(pDX, IDC_LOADSEQ_EDIT_FROM, m_from);
DDV_MinMaxInt(pDX, m_from, 0, 9999);
DDX_Text(pDX, IDC_LOADSEQ_EDIT_MESSAGE, m_message);
DDX_Text(pDX, IDC_LOADSEQ_EDIT_TO, m_to);
DDV_MinMaxInt(pDX, m_to, 0, 9999);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgLoadSequence, CDialog)
//{{AFX_MSG_MAP(CDlgLoadSequence)
ON_BN_CLICKED(IDC_LOADSEQ_BUTTON_APPLY, OnLoadseqButtonApply)
ON_BN_CLICKED(IDC_LOADSEQ_BUTTON_CANCEL, OnLoadseqButtonCancel)
ON_BN_CLICKED(IDC_LOADSEQ_BUTTON_DONE, OnLoadseqButtonDone)
ON_EN_CHANGE(IDC_LOADSEQ_EDIT_FROM, OnChangeLoadseqEditFrom)
ON_EN_CHANGE(IDC_LOADSEQ_EDIT_TO, OnChangeLoadseqEditTo)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgLoadSequence message handlers
void CDlgLoadSequence::OnLoadseqButtonApply()
{
UpdateData(TRUE);
if( m_from > m_to)
{
MessageBox("<To> value cannot be less than <From> value.",
NULL, MB_OK|MB_ICONWARNING);
m_from = m_start;
m_to = m_end;
}
if( m_from < m_start)
{
MessageBox("<From> value cannot be less than first frame number.",
NULL, MB_OK|MB_ICONWARNING);
m_from = m_start;
}
if( m_to > m_end)
{
MessageBox("<To> value cannot be greater than last frame number.",
NULL, MB_OK|MB_ICONWARNING);
m_to = m_end;
}
m_message = "Press <Done> to load " + m_seqName;
m_verify = TRUE;
UpdateData(FALSE);
}
void CDlgLoadSequence::OnLoadseqButtonCancel()
{
EndDialog(IDCANCEL);
}
void CDlgLoadSequence::OnLoadseqButtonDone()
{
if( m_verify) EndDialog(IDOK);
}
void CDlgLoadSequence::OnChangeLoadseqEditFrom()
{
UpdateData(TRUE);
m_message = "Press <Apply> to verify range";
m_verify = FALSE;
UpdateData(FALSE);
}
void CDlgLoadSequence::OnChangeLoadseqEditTo()
{
UpdateData(TRUE);
m_message = "Press <Apply> to verify range";
m_verify = FALSE;
UpdateData(FALSE);
}
void CDlgLoadSequence::OnOK()
{
// overrides base function
}
void CDlgLoadSequence::OnCancel()
{
// overrides base function
}
int CDlgLoadSequence::prepareLoadSequence(CString strFileName,
CString strFileTitle)
{
int nPeriod;
int nFileNumber;
CString strLeft;
CString strLeftWoutNumber;
CString strFileNumber;
char chNumber[5];
// Get the file number of the image file
nPeriod = strFileName.Find('.');
strLeft = strFileName.Left(nPeriod);
strFileNumber = strLeft.Right(4);
chNumber[0] = strFileNumber[0];
chNumber[1] = strFileNumber[1];
chNumber[2] = strFileNumber[2];
chNumber[3] = strFileNumber[3];
chNumber[4] = '\0';
nFileNumber = atoi(chNumber);
CFile tmpFile;
CString strTmpNumber;
CString strTmpFileName;
int nTmpFileNumber;
strLeftWoutNumber = strLeft.Left(nPeriod-4);
nTmpFileNumber = nFileNumber - 1;
strTmpNumber.Format("%04d", nTmpFileNumber);
strTmpFileName = strLeftWoutNumber + strTmpNumber + ".bmp";
while( tmpFile.Open(strTmpFileName, CFile::modeRead, NULL))
{
tmpFile.Close();
nTmpFileNumber--;
strTmpNumber.Format("%04d", nTmpFileNumber);
strTmpFileName = strLeftWoutNumber + strTmpNumber + ".bmp";
}
m_start = nTmpFileNumber + 1;
m_from = m_start;
nTmpFileNumber = nFileNumber + 1;
strTmpNumber.Format("%04d", nTmpFileNumber);
strTmpFileName = strLeftWoutNumber + strTmpNumber + ".bmp";
while( tmpFile.Open(strTmpFileName, CFile::modeRead, NULL))
{
tmpFile.Close();
nTmpFileNumber++;
strTmpNumber.Format("%04d", nTmpFileNumber);
strTmpFileName = strLeftWoutNumber + strTmpNumber + ".bmp";
}
m_end = nTmpFileNumber - 1;
m_to = m_end;
CString strFileTitleWoutNumber;
nPeriod = strFileTitle.Find('.');
strFileTitleWoutNumber = strFileTitle.Left(nPeriod-4);
m_seqName = strFileTitleWoutNumber;
m_seqNameFull = strLeftWoutNumber;
m_message = "Press <Done> to load " + m_seqName;
m_verify = TRUE;
return (m_end - m_start);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -