要在void CMy2DHotWireCuttingDlg::Onmenufileimport()进行填补

// 2DHotWireCuttingDlg.cpp : 实现文件

//

#include "stdafx.h"

#include "2DHotWireCutting.h"

#include "2DHotWireCuttingDlg.h"

#include  "foamMachiningSet.h"

#include "afxdialogex.h"

#include "xsleep.h"

#ifdef _DEBUG

#define new DEBUG_NEW

#endif

#define CUT_OUTER 1

bool m_bExitThread;

bool b_showBlkImage;                            //用于显示BLK图像的标志

extern bool b_saveblkimage;

vector<fPoint> blkcoordinate;

vector<fPoint> g_printblkcoordinate;

vector<vector <fPoint> >blkImageDatas; //用于存储BLK图像的坐标数组的

vector<vector <fPoint> >g_savePrintBlockPos;

CString g_deleteFileName;

fPoint g_posShowCenter;                        //求出中心点的坐标

CString g_curDirectoryPath;

bool b_framecutting;            //带框切割

char g_curPath[256];

extern bool b_saveblkimage;

extern bool g_closeDigitizerPort;

extern bool g_finishCuttingFlag;

//用于应用程序"关于"菜单的CAboutDlg对话框

class CAboutDlg : public CDialogEx

{

public:

CAboutDlg();

//对话框数据

enum { IDD = IDD_ABOUTBOX };

protected:

virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV支持

//实现

protected:

DECLARE_MESSAGE_MAP()

};

CAboutDlg::CAboutDlg() : CDialogEx(CAboutDlg::IDD)

{

}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)

{

CDialogEx::DoDataExchange(pDX);

}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)

END_MESSAGE_MAP()

// CMy2DHotWireCuttingDlg 对话框

CMy2DHotWireCuttingDlg::CMy2DHotWireCuttingDlg(CWnd* pParent /*=NULL*/)

: CDialogEx(CMy2DHotWireCuttingDlg::IDD, pParent)

{

m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);

b_isSetup = false;

m_bExitThread = true;

}

CMy2DHotWireCuttingDlg::~CMy2DHotWireCuttingDlg()

{

//Gdiplus::GdiplusShutdown(m_gdiplusToken);

}

void CMy2DHotWireCuttingDlg::DoDataExchange(CDataExchange* pDX)

{

CDialogEx::DoDataExchange(pDX);

DDX_Control(pDX, IDC_TAB1, m_tab);

DDX_Control(pDX, IDC_LIST_patienData, m_list_patientData);

DDX_Control(pDX, IDC_LIST3, m_list_Icon);

}

BEGIN_MESSAGE_MAP(CMy2DHotWireCuttingDlg, CDialogEx)

ON_WM_SYSCOMMAND()

ON_WM_PAINT()

ON_WM_QUERYDRAGICON()

//--------------------------------------------------------------------------------------

//验证打印

ON_MESSAGE(WM_BEGIN_PRINTING,OnBeginPrinting)

ON_MESSAGE(WM_END_PRINTING,OnEndPrinting)

ON_MESSAGE(WM_MY_PRINT,OnMyPrint)

//--------------------------------------------------------------------------------------

//ON_COMMAND(ID_menu_saveBMP, &CMy2DHotWireCuttingDlg::Onmenusavebmp)

ON_COMMAND(ID_menu_backupsData, &CMy2DHotWireCuttingDlg::Onmenubackupsdata)

ON_COMMAND(ID_menu_importData, &CMy2DHotWireCuttingDlg::Onmenuimportdata)

ON_COMMAND(ID_menu_printf, &CMy2DHotWireCuttingDlg::Onmenuprintf)

ON_COMMAND(ID_menu_exit, &CMy2DHotWireCuttingDlg::Onmenuexit)

ON_COMMAND(ID_menu_addPatientData, &CMy2DHotWireCuttingDlg::Onmenuaddpatientdata)

ON_COMMAND(ID_menu_deletePatientData, &CMy2DHotWireCuttingDlg::Onmenudeletepatientdata)

ON_COMMAND(ID_menu_revisPatientData, &CMy2DHotWireCuttingDlg::Onmenurevispatientdata)

ON_COMMAND(ID_menu_forwardLook, &CMy2DHotWireCuttingDlg::Onmenuforwardlook)

ON_COMMAND(ID_menu_backwardLook, &CMy2DHotWireCuttingDlg::Onmenubackwardlook)

ON_COMMAND(ID_menu_fileImport, &CMy2DHotWireCuttingDlg::Onmenufileimport)

ON_COMMAND(ID_menu_DigitizerImport, &CMy2DHotWireCuttingDlg::OnmenuDigitizerimport)

ON_COMMAND(ID_menu_standardBlock, &CMy2DHotWireCuttingDlg::Onmenustandardblock)

ON_COMMAND(ID_menu_set, &CMy2DHotWireCuttingDlg::Onmenuset)

ON_COMMAND(ID_menu_Administrators, &CMy2DHotWireCuttingDlg::OnmenuAdministrators)

ON_COMMAND(ID_menu_Cancellation, &CMy2DHotWireCuttingDlg::OnmenuCancellation)

ON_COMMAND(ID_menu_revisAdministrators, &CMy2DHotWireCuttingDlg::Onmenurevisadministrators)

ON_COMMAND(ID_menu_register, &CMy2DHotWireCuttingDlg::Onmenuregister)

ON_COMMAND(ID_menu_DigitizerTest, &CMy2DHotWireCuttingDlg::OnmenuDigitizertest)

ON_COMMAND(ID_menu_about, &CMy2DHotWireCuttingDlg::Onmenuabout)

ON_NOTIFY(TCN_SELCHANGE, IDC_TAB1, &CMy2DHotWireCuttingDlg::OnTcnSelchangeTab1)

ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST_patienData, &CMy2DHotWireCuttingDlg::OnLvnItemchangedListpatiendata)

ON_COMMAND(ID_32842, &CMy2DHotWireCuttingDlg::Onchain)

ON_COMMAND(ID_32843, &CMy2DHotWireCuttingDlg::OnEnglish)

ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST3, &CMy2DHotWireCuttingDlg::OnLvnItemchangedList3)

ON_NOTIFY(NM_DBLCLK, IDC_LIST3, &CMy2DHotWireCuttingDlg::OnNMDblclkList3)

ON_WM_TIMER()

ON_WM_CTLCOLOR()

ON_WM_KEYDOWN()

ON_NOTIFY(LVN_BEGINDRAG, IDC_LIST3, &CMy2DHotWireCuttingDlg::OnLvnBegindragList3)

ON_WM_LBUTTONDOWN()

ON_WM_LBUTTONUP()

ON_WM_MOUSEMOVE()

ON_NOTIFY(NM_RCLICK, IDC_LIST3, &CMy2DHotWireCuttingDlg::OnNMRClickList3)

ON_COMMAND(ID_32847, &CMy2DHotWireCuttingDlg::OnAddCuting)

ON_COMMAND(ID_ADDTOCUTTING_ADDTOCUTTING,&CMy2DHotWireCuttingDlg::OnAddCuting)

ON_COMMAND(ID_DELETE_ICON,&CMy2DHotWireCuttingDlg::OnDeleteIcon)

ON_COMMAND(ID_mirrorLR, &CMy2DHotWireCuttingDlg::Onmirrorlr)

ON_COMMAND(ID_mirrorUD, &CMy2DHotWireCuttingDlg::Onmirrorud)

ON_COMMAND(ID_deleteBlock, &CMy2DHotWireCuttingDlg::Ondeleteblock)

ON_WM_CLOSE()

END_MESSAGE_MAP()

// CMy2DHotWireCuttingDlg 消息处理程序

BOOL CMy2DHotWireCuttingDlg::OnInitDialog()

{

CDialogEx::OnInitDialog();

GetCurrentDirectory(MAX_PATH,g_curPath);

strcat(g_curPath,"\\");

g_curDirectoryPath=g_curPath;

//将“关于...”菜单项添加到系统菜单中。

// IDM_ABOUTBOX必须在系统命令范围内。

ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);

ASSERT(IDM_ABOUTBOX < 0xF000);

CMenu* pSysMenu = GetSystemMenu(FALSE);

if (pSysMenu != NULL)

{

BOOL bNameValid;

CString strAboutMenu;

bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);

ASSERT(bNameValid);

if (!strAboutMenu.IsEmpty())

{

pSysMenu->AppendMenu(MF_SEPARATOR);

pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);

}

}

// 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动

//  执行此操作

SetIcon(m_hIcon, TRUE); // 设置大图标

SetIcon(m_hIcon, FALSE); // 设置小图标

//ergodicPrint();  //检测是否有打印机

CorE = false;    //中英界面

b_addCutingImgs = false;

printfPath = "";

blockPath = "";

//--------------------------------------------------------------泡沫显示挡块---------------------------------------------------------------

GetDlgItem(IDC_STATIC_showFeild)->GetWindowRect(&showRect);//获取控件相对于屏幕的位置

ScreenToClient(showRect); 

showBlockBkImg.loadShowImage(g_curDirectoryPath + "res\\background.JPG");

b_listDrag = false;            //列表拖动

b_mouseButtonDown = false;      //鼠标左键按下

b_mouseButtonUp = false;        //鼠标左键松开

b_mouseButtonMove = false;      //鼠标移动

////-----------------------------------------------------------注册----------------------------------------------------------------

/* CStdioFile *reg;

reg = new CStdioFile();

CString regFilePath;

regFilePath = g_curDirectoryPath + "res\\reg.bat";

CString ActivationCode;

if (reg->Open(regFilePath,CFile::modeRead))

{

reg->SeekToBegin();

reg->ReadString(ActivationCode);

reg->Close();

}

char lpszMac[1024];

memset(lpszMac, 0x00, sizeof(lpszMac));

//获取MAC

m_addregister.GetMacByCmd(lpszMac);

int iMacSize = strlen(lpszMac);

// lpszMac[iMacSize - 1] = '\0';

char tfy[5] = "TFY";

strcat(lpszMac,tfy);

MD5 md5;                          //定义MD5的类

CString aaaaa;                    //需要加密的字符串

md5.update(lpszMac);              //因为update函数只接收string类型,所以使用getbuffer()函数转换CString为string

aaaaa=md5.toString().c_str();    //toString()函数获得加密字符串,c_str();函数重新转换成CString类型

if (ActivationCode != aaaaa)

{

m_addregister.setActivationCode(false);

m_addregister.DoModal();

}

else

{

m_addregister.setActivationCode(true);

}

*/

//-------------------------------------------------------------dlg-------------------------------------------------------------

m_digitizerInput=new digitizerInput();

m_digitizerInput->Create(IDD_DIALOG_digitizerInput,GetDlgItem(IDC_STATIC_group));

m_digitizerInput->ShowWindow(SW_HIDE);

m_debugging.newDlg();

m_debugging.dlg->Create(IDD_DIALOG_debugMain,GetDlgItem(IDC_STATIC_group));

m_debugging.dlg->ShowWindow(SW_HIDE);

m_blockShow = new blockShow();

m_blockShow->Create(IDD_DIALOG_blockShow,GetDlgItem(IDC_STATIC_blockShow));

m_blockShow->ShowWindow(SW_HIDE);

GetDlgItem(IDC_STATIC_blockShow)->ShowWindow(SW_HIDE);

GetDlgItem(IDC_STATIC_group)->ShowWindow(SW_HIDE);

//GetDlgItem(IDC_STATIC_blockShow)->ShowWindow(SW_HIDE);

b_digitizerShow = false;

//-------------------------------------------------------创建拷贝文件夹----------------------------------------------------------

CString m_backupsPath="C:\\Program Files\\TFY-backups"; 

//判断路径是否存在 

if(!PathIsDirectory(m_backupsPath)) 

CreateDirectory(m_backupsPath,NULL);

}

// TODO: 在此添加额外的初始化代码

//-------------------------------------------------------工具栏-----------------------------------------------------------------

//创建工具栏 

m_toolbar.CreateEx(this);                    //创建空白工具栏 

m_toolbar.LoadToolBar(IDR_TOOLBAR1);          //加载工具栏资源 

m_ImageList.Create(32,32,ILC_COLORDDB|ILC_MASK,1,1);

CBitmap bmp;

for(int i=0;i<12;i++)

{

//添加按钮图标

bmp.LoadBitmap(IDB_BITMAP1+i);

m_ImageList.Add(&bmp,RGB(255,255,255));

bmp.DeleteObject();

}

m_toolbar.SetButtonText(0,"Add");

m_toolbar.SetButtonText(1,"Delete");

m_toolbar.SetButtonText(2,"Modify");

m_toolbar.SetButtonText(4,"Forward");

m_toolbar.SetButtonText(5,"Backwards");

m_toolbar.SetButtonText(7,"Digitizer");

m_toolbar.SetButtonText(8,"File");

m_toolbar.SetButtonText(9,"Standard");

m_toolbar.SetButtonText(11,"Set");

m_toolbar.SetButtonText(12,"Print");

m_toolbar.GetToolBarCtrl().SetImageList(&m_ImageList);

m_toolbar.SetSizes(CSize(60,50),CSize(32,32)); //设置按钮和按钮位图大小

CRect rect; 

GetClientRect(&rect);                        //计算客户区大小 

m_toolbar.MoveWindow(0,0,rect.Width(), 38);  //必须设置工具栏显示位置

    //客户区向下移动

CRect rcClientOld; //客户区RECT

CRect rcClientNew; //加入TOOLBAR后的CLIENT RECT

GetClientRect(rcClientOld);

//重新计算RECT大小

RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,0,reposQuery,rcClientNew);

//所有的子窗口将被移动,以免被TOOLBAR覆盖

//计算移动的距离

CPoint ptOffset(rcClientNew.left-rcClientOld.left,

rcClientNew.top-rcClientOld.top);

CRect rcChild;

CWnd* pwndChild = GetWindow(GW_CHILD); //得到子窗口

while(pwndChild) // 处理所有子窗口

{//移动所有子窗口

pwndChild-> GetWindowRect(rcChild);

ScreenToClient(rcChild);

rcChild.OffsetRect(ptOffset);

pwndChild-> MoveWindow(rcChild,FALSE);

pwndChild = pwndChild-> GetNextWindow();

}

CRect rcWindow;

GetWindowRect(rcWindow); // 得到对话框RECT

rcWindow.right += rcClientOld.Width() - rcClientNew.Width(); // 修改对话框尺寸

rcWindow.bottom += rcClientOld.Height() - rcClientNew.Height();

MoveWindow(rcWindow,FALSE); // Redraw Window

RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,0);

//------------------------------------------------------------tab面板---------------------------------------------------------------------

m_tab.InsertItem(0, "MainInterFace");      // 插入第一个标签“主界面” 

m_tab.InsertItem(1, "PatientQuery");    // 插入第二个标签“病人查询”

m_tab.InsertItem(2, "Debugging");        // 插入第二个标签“调试”

m_mainInterface.Create(IDD_MainInterface,&m_tab);

m_patienQuery.Create(IDD_patientQuery,&m_tab);

m_debugging.Create(IDD_debug,&m_tab);

CRect tabRect;  // 标签控件客户区的位置和大小

m_tab.GetClientRect(&tabRect);    // 获取标签控件客户区Rect 

// 调整tabRect,使其覆盖范围适合放置标签页 

tabRect.left += 1;                 

tabRect.right -= 1; 

tabRect.top += 25; 

tabRect.bottom -= 1; 

// 根据调整好的tabRect放置m_jzmDlg子对话框,并设置为显示 

m_mainInterface.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_SHOWWINDOW); 

// 根据调整好的tabRect放置m_androidDlg子对话框,并设置为隐藏 

m_patienQuery.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_HIDEWINDOW);

m_debugging.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_HIDEWINDOW);

//-----------------------------------------------------------病人信息列表----------------------------------------------------------------------

//添加表格

m_list_patientData.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_DOUBLEBUFFER);

m_list_patientData.InsertColumn(0,"ID",LVCFMT_LEFT,60);        //Ìí¼ÓÁбêÌâ  ÕâÀïµÄ80,40,90ÓÃÒÔÉèÖÃÁеĿí¶È¡£LVCFMT_LEFTÓÃÀ´ÉèÖöÔÆ뷽ʽ

m_list_patientData.InsertColumn(1,"Name",LVCFMT_LEFT,60);

m_list_patientData.InsertColumn(2,"RadiotherapyNumber",LVCFMT_LEFT,60);

m_list_patientData.InsertColumn(3,"Age",LVCFMT_LEFT,60);

m_list_patientData.InsertColumn(4,"Sex",LVCFMT_LEFT,60);

m_list_patientData.InsertColumn(5,"Time",LVCFMT_LEFT,180);

m_list_patientData.InsertColumn(6,"Field",LVCFMT_LEFT,80);

m_list_patientData.InsertColumn(7,"Remarks",LVCFMT_LEFT,80);

getRecordsData();

//---------------------------------------------------GDI+------------------------------------------------------------

// Gdiplus::GdiplusStartupInput gdiplusStartupInput;

// Gdiplus::GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);

//---------------------------------------------------图片绘制---------------------------------------------------------

GetDlgItem(IDC_LIST3)->GetWindowRect(&backgroundRect);

ScreenToClient(backgroundRect);

clickedListId = 0;

b_isSetup = true;

SetTimer(1,10,NULL);

SetTimer(2,10,NULL);

showBlockMove = new showImage;

showBlockMove->loadShowImage(g_curDirectoryPath + "res\\Panel.jpg");

b_clearBlock = false;

b_AddCuting = false;

//---------------------------------------------------测试---------------------------------------------------------

m_il.Create(128,128,ILC_COLOR32|ILC_MASK,10,2);    //初始化图片列表图片容器

OnEnglish();  // 新华的英文版是独立的版本

CorE = TRUE;

g_finishCuttingFlag = false;

m_debugging.startTimer();

CStdioFile* myFilefoamMachiningSet;

myFilefoamMachiningSet = new CStdioFile();

CString filePath;

filePath = "res\\backupsFile\\parametersSet\\foamMachiningSet.xml";

CString str_lectroniclinemode;      //电子线模式

CString str_framecutting;            //带框切割

CString str_tapercutting;            //锥度带框切割

CString str_everyrowidentical;      //每行的x起始位置都与第一行相同

CString str_manualpath;              //手动路径

CString str_showstartline;          //显示起始线

CString str_showsign ; 

if(myFilefoamMachiningSet->Open(filePath,CFile::modeRead))

{

myFilefoamMachiningSet->ReadString(str_lectroniclinemode);

myFilefoamMachiningSet->ReadString(str_framecutting);

myFilefoamMachiningSet->ReadString(str_tapercutting);

myFilefoamMachiningSet->ReadString(str_everyrowidentical);

myFilefoamMachiningSet->ReadString(str_manualpath);

myFilefoamMachiningSet->ReadString(str_showstartline);

myFilefoamMachiningSet->ReadString(str_showsign);

myFilefoamMachiningSet->Close();

}

b_framecutting = atoi(str_framecutting);            //带框切割

return TRUE;

}

void CMy2DHotWireCuttingDlg::OnSysCommand(UINT nID, LPARAM lParam)

{

if ((nID & 0xFFF0) == IDM_ABOUTBOX)

{

CAboutDlg dlgAbout;

dlgAbout.DoModal();

}

else

{

CDialogEx::OnSysCommand(nID, lParam);

}

}

// 如果向对话框添加最小化按钮,则需要下面的代码

//  来绘制该图标。对于使用文档/视图模型的 MFC 应用程序,

//  这将由框架自动完成。

void CMy2DHotWireCuttingDlg::OnPaint()

{

if (IsIconic())

{

CPaintDC dc(this); // 用于绘制的设备上下文

SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);

// 使图标在工作区矩形中居中

int cxIcon = GetSystemMetrics(SM_CXICON);

int cyIcon = GetSystemMetrics(SM_CYICON);

CRect rect;

GetClientRect(&rect);

int x = (rect.Width() - cxIcon + 1) / 2;

int y = (rect.Height() - cyIcon + 1) / 2;

// 绘制图标

dc.DrawIcon(x, y, m_hIcon);

}

else

{

drawBlockBk(1);

CDialogEx::OnPaint();

}

}

//画泡沫显示

void CMy2DHotWireCuttingDlg::drawBlockBk(int _type)

{

//Sleep(10);

if (_type == 0)

{

CDC *mDc;

mDc = GetDlgItem(IDC_STATIC_showFeild)->GetDC();

showBlockMove->loadShowImage(g_curDirectoryPath + "res\\Panel.jpg");

showBlockBkImg.drawShowImage(mDc->m_hDC,0,8);

showBlockMove->drawShowImage(mDc->m_hDC,91,99);

}

else

{

CDC *mDc;

mDc = GetDlgItem(IDC_STATIC_showFeild)->GetDC();

showBlockBkImg.drawShowImage(mDc->m_hDC,0,8);

showBlockMove->drawShowImage(mDc->m_hDC,91,99);

}

// CDC *mDc;

// mDc = GetDlgItem(IDC_STATIC_showFeild)->GetDC();

//

// CPen penRed(PS_SOLID,1,RGB(255,0,0));

//

// mDc->SelectObject(&penRed);

// mDc->MoveTo(58,578);                  //画标示线横

// mDc->LineTo(340,578);                //画标示线横

//

// mDc->MoveTo(105,16);                  //画标示线竖

// mDc->LineTo(105,623);                //画标示线竖

}

//当用户拖动最小化窗口时系统调用此函数取得光标

//显示。

HCURSOR CMy2DHotWireCuttingDlg::OnQueryDragIcon()

{

return static_cast<HCURSOR>(m_hIcon);

}

//----------------------------------------------文件备份(复制文件)---------------------------------------------------------

void CMy2DHotWireCuttingDlg::copyFile(CString _suorce, CString _target)

{

CreateDirectory(_target,NULL); //获取目标拷贝的路径 拷贝至哪里 

CFileFind finder;   

CString path=_suorce+_T("\\*.*"); //需要拷贝的文件的路径 

bool bWorking = finder.FindFile(path);  //是否找到了需要拷贝的文件的路径 

while(bWorking){   

bWorking = finder.FindNextFile();   

if(finder.IsDirectory() && !finder.IsDots())

{ //是不是有效的文件夹 

copyFile(finder.GetFilePath(),_target+_T("\\")+finder.GetFileName()); //递归查找文件夹 

}   

else{ //是文件则直接复制 

CopyFile(finder.GetFilePath(),_target+_T("\\")+finder.GetFileName(),FALSE);  //拷贝文件夹下的所有文件 

}   

}   

}

//---------------------------------------------------列表添加图标-----------------------------------------------------------

void CMy2DHotWireCuttingDlg::addIcon(CString _fileName, int _id)

{

img = new CImage;

img->Load(_fileName);

{

CImage *pStretchImage = new CImage;

pStretchImage->Create(128,128,24,0);

img->StretchBlt(pStretchImage->GetDC(), 0, 0, 128,128, SRCCOPY);

pStretchImage->ReleaseDC();

delete img;

HBITMAP hbmp =(HBITMAP)pStretchImage->operator HBITMAP();

CBitmap bm;

if(hbmp)

{

bm.Attach(hbmp);

m_il.Add(&bm,RGB(100,100,100));

bm.Detach();

DeleteObject(hbmp); //zwt fixed memory leak

}

}

}

//---------------------------------------------------显示列表图标-----------------------------------------------------------

void CMy2DHotWireCuttingDlg::showIcon(int _id)

{

CString imgName;

imgName.Format("%d",_id);

m_list_Icon.InsertItem(_id,imgName,_id);

}

//-------------------------------------------------¸üÐÂÖ¸¶¨²¡ÈËÐÅÏ¢-----------------------------------------------------------

//¸üÐÂÁÐ±í²¡ÀúÐÅÏ¢

void CMy2DHotWireCuttingDlg::updateOneRecordsData(int _id, int _type) 

{

CString bingliFile = g_curDirectoryPath + "res\\backupsFile\\records";

m_FileList = m_pData.GetFileFromDirXML(bingliFile);

CStdioFile* myFilebingli;

myFilebingli = new CStdioFile();

int nRow;

CString fString;

if (_type == 1)

{

CString str;

str.Format("%d",m_FileList.size());

nRow = m_list_patientData.InsertItem (m_FileList.size(),str);

fString = bingliFile+"\\"+m_FileList[m_FileList.size()-1];

}

else if (_type == 0)

{

nRow = _id;

fString = bingliFile+"\\"+m_FileList[_id+1];

}

if(myFilebingli->Open(fString,CFile::modeRead))

{

int tttt = 0;

CString tempStr;

chaxunBingli queryTemp;

while (myFilebingli->ReadString(tempStr))

{

m_list_patientData.SetItemText(nRow,tttt,tempStr);

tttt++;

}

myFilebingli->Close();

}

delete myFilebingli;

}

//获取所有病历信息

void CMy2DHotWireCuttingDlg::getRecordsData()

{

CString bingliFile = g_curDirectoryPath + "res\\backupsFile\\records";

m_FileList = m_pData.GetFileFromDirXML(bingliFile);

while(m_list_patientData.DeleteItem(0));

vector<CString> s_tempName;        //记录所有姓名

vector<CString> s_tempRnumber;    //记录所有放疗号

vector<CString> s_fileName;        //记录所有文件名k

str1.clear();

if (m_FileList[0] == "xml.xml" && m_FileList.size() > 1)

{

for (int i = 1; i < m_FileList.size(); i++)

{

CString str;

str.Format("%d",i-1);

int nRow = m_list_patientData.InsertItem (i-1,str);

CStdioFile* myFilebingli;

myFilebingli = new CStdioFile();

CString fString;

fString = bingliFile+"\\"+m_FileList[i];

s_fileName.push_back(fString);

if(myFilebingli->Open(fString,CFile::modeRead))

{

int tttt = 0;

CString tempStr;

chaxunBingli queryTemp;

while (myFilebingli->ReadString(tempStr))

{

m_list_patientData.SetItemText(nRow,tttt,tempStr);

str1.push_back(tempStr);

if (tttt == 1)

{

s_tempName.push_back(tempStr);

}

if(tttt == 2)

{

s_tempRnumber.push_back(tempStr);

}

tttt++;

}

myFilebingli->Close();

}

delete myFilebingli;//zwt solve memory leak

}

}

m_patienQuery.setNameAndRadiotherapyNumber(s_tempName,s_tempRnumber,s_fileName);

m_addPatienData.setNameAndRadiotherapyNumber(s_tempName,s_tempRnumber,s_fileName);

}

/*删除目录及目录中的所有内容*/

BOOL CMy2DHotWireCuttingDlg::DeleteFolder(LPCTSTR pstrFolder)

{

if ((NULL == pstrFolder))

{

return FALSE;

}

/*检查输入目录是否是合法目录*/

// if (!IsDirectory(pstrFolder))

// {

// return FALSE;

// }

/*创建源目录中查找文件的通配符*/

CString strWildcard(pstrFolder);

if(strWildcard.Right(1) != _T('\\'))

{

strWildcard += _T("\\");

}

strWildcard += _T("*.*");

/*打开文件查找,查看源目录中是否存在匹配的文件*/

/*调用FindFile后,必须调用FindNextFile才能获得查找文件的信息*/

CFileFind finder;

BOOL bWorking = finder.FindFile(strWildcard);

while(bWorking)

{

/*查找下一个文件*/

bWorking = finder.FindNextFile();

/*跳过当前目录“.”和上一级目录“..”*/

if(finder.IsDots())

{

continue;

}

/*得到当前目录的子文件的路径*/

CString strSubFile = finder.GetFilePath();

/*判断当前文件是否是目录,*/

/*如果是目录,递归调用删除目录,*/

/*否则,直接删除文件*/

if(finder.IsDirectory())

{

if (!DeleteFolder(strSubFile))

{

finder.Close();

return FALSE;

}

}

else

{

if (!DeleteFile(strSubFile))

{

finder.Close();

return FALSE;

}

}

}

/*while (bWorking)*/

/*关闭文件查找*/

finder.Close();

/*删除空目录*/;

return RemoveDirectory(pstrFolder);

}

//----------------------------------------------------更新主面板病历信息------------------------------------------------------------

void CMy2DHotWireCuttingDlg::updataRecordsData(CString _str, int _id, int _type)

{

CStdioFile *m_mainInterfaceRecordsData;

m_mainInterfaceRecordsData = new CStdioFile();

if (m_mainInterfaceRecordsData->Open(_str,CFile::modeRead))

{

m_mainInterfaceRecordsData->SeekToBegin();

m_mainInterfaceRecordsData->ReadString(m_mainInterface.edit_main_id);          //传值给主界面面板显示

m_patientQD.queryPatientData_ID = m_mainInterface.edit_main_id;                //传值给修改界面

str1[0] = m_mainInterface.edit_main_id;

m_mainInterfaceRecordsData->ReadString(m_mainInterface.edit_main_name);

m_patientQD.queryPatientData_Name = m_mainInterface.edit_main_name;

str1[1] = m_mainInterface.edit_main_name;

m_mainInterfaceRecordsData->ReadString(m_mainInterface.edit_main_radiotherapyNumber);

m_patientQD.queryPatinetData_radiotherapyNumber = m_mainInterface.edit_main_radiotherapyNumber;

str1[2] =m_mainInterface.edit_main_radiotherapyNumber;

m_mainInterfaceRecordsData->ReadString(m_mainInterface.edit_main_age);

m_patientQD.queryPatientData_age = m_mainInterface.edit_main_age;

str1[3] = m_mainInterface.edit_main_age;

m_mainInterfaceRecordsData->ReadString(m_mainInterface.edit_main_sex);

m_patientQD.queryPatientData_sex = m_mainInterface.edit_main_sex;

str1[4] = m_mainInterface.edit_main_sex;

m_mainInterfaceRecordsData->ReadString(m_mainInterface.edit_main_time);

m_patientQD.queryPatientData_time = m_mainInterface.edit_main_time;

str1[5] = m_mainInterface.edit_main_time;

m_mainInterfaceRecordsData->ReadString(m_mainInterface.edit_main_fieldNumber);

m_patientQD.queryPatientData_fieldNumber = m_mainInterface.edit_main_fieldNumber;

str1[6] = m_mainInterface.edit_main_fieldNumber;

m_mainInterfaceRecordsData->ReadString(m_mainInterface.edit_main_remarks);

m_patientQD.queryPatientData_remarks = m_mainInterface.edit_main_remarks;

str1[7] = m_mainInterface.edit_main_remarks;

m_mainInterface.UpdateData(FALSE);

m_mainInterfaceRecordsData->Close();

}

delete m_mainInterfaceRecordsData; //zwt solve memory leak

}

//---------------------------------------------------------打印-------------------------------------------------------------

//开始打印-ok

LRESULT CMy2DHotWireCuttingDlg::OnBeginPrinting(WPARAM wParam,LPARAM lParam)

{

CDC* pDC = (CDC*)wParam;

CPrintInfo* pInfo = (CPrintInfo *)lParam;

if(m_fontPrinter.m_hObject==NULL)

m_fontPrinter.CreatePointFont(120,"FixedSys",pDC);

TEXTMETRIC tm;

CFont* pOldFont = pDC->SelectObject (&m_fontPrinter);

pDC->GetTextMetrics (&tm);

m_cyPrinter = tm.tmHeight + tm.tmExternalLeading;

// CSize size = pDC->GetTextExtent (_T ("---------1---------2---------" \

// "3---------4---------5---------6---------7---------8---"), 81);

CSize size = pDC->GetTextExtent (_T ("-" \

"1-"), 136);

pDC->SelectObject (pOldFont);

m_cxWidth = size.cx;

m_nLinesPerPage = (pDC->GetDeviceCaps (VERTRES) -

(m_cyPrinter * (3 + (2 * PRINTMARGIN)))) / m_cyPrinter;

//pInfo->SetMaxPage (1);

m_cxOffset = (pDC->GetDeviceCaps (HORZRES) - size.cx) / 2;

return TRUE;

}

//结束打印

LRESULT CMy2DHotWireCuttingDlg::OnEndPrinting(WPARAM wParam,LPARAM lParam)

{

if(m_fontPrinter.m_hObject!=NULL)

m_fontPrinter.DeleteObject ();

return TRUE;

}

//打印内容

LRESULT CMy2DHotWireCuttingDlg::OnMyPrint(WPARAM wParam,LPARAM lParam)

{

CDC* pDC                  =(CDC*)wParam;

CFont font;//字体类型

CFont *oldfont;

CPoint point;

CString ss="Use print preview in dialog";

int nWidth=pDC->GetDeviceCaps(HORZRES); //得到纸张的宽度

int nHeight=pDC->GetDeviceCaps(VERTRES);//得到纸张的宽度

int ghdf=pDC->GetDeviceCaps(LOGPIXELSY);//得到纸张的像素dpi

CRect DrawRect(0,0,nWidth,nHeight),imgDrawRect(0,0,nWidth,nHeight);

// HBITMAP hBitmap = (HBITMAP)LoadImage(NULL, "res\\backupsFile\\image\\2017-09-20-10-12-12\\1254631.bmp", IMAGE_BITMAP,0, 0, LR_CREATEDIBSECTION |LR_DEFAULTSIZE | LR_LOADFROMFILE);

//原作者在显示图片时,用的函数为LoadBitmap(),这个函数的功能有限,而且必须将图片加载到mfc中的位图中,对于想要动态显示图片的话,很不方便,所我采用了 LoadImage()函数

// BITMAP bitmap;

// ::GetObject(hBitmap,sizeof(BITMAP),&bitmap);

// double dScale=(double)m_cxWidth/bitmap.bmWidth;

// int nScaledWidth=m_cxWidth;

// int nScaledHeight=(int)(bitmap.bmHeight*dScale);

//

// HDC dcMem;

// dcMem=::CreateCompatibleDC(pDC->m_hDC);

// HBITMAP hOldBmp=(HBITMAP)::SelectObject(dcMem,hBitmap);

//-----------------------------------------------------------------------------------------------------------------

CString tXY;

//获得系统日期

SYSTEMTIME st;

CString strDate;

GetLocalTime(&st);

strDate.Format("%4dYear%2dMonth%2dDay",st.wYear,st.wMonth,st.wDay);

//医院

font.CreateFont(-MulDiv(25,-pDC->GetDeviceCaps(LOGPIXELSY),72),0,0,0,FW_NORMAL,0,0,0,GB2312_CHARSET,OUT_STROKE_PRECIS,CLIP_STROKE_PRECIS,DRAFT_QUALITY,VARIABLE_PITCH|FF_SWISS,_T("MS Serif"));//25为字体大小

oldfont=pDC->SelectObject(&font);//设置字体

DrawRect = CRect(0,100,nWidth,nHeight);

pDC->DrawText("Hospital",&DrawRect,DT_CENTER|DT_TOP|DT_SINGLELINE);//将文字绘出来

font.DeleteObject();

font.CreateFont(-MulDiv(8,-pDC->GetDeviceCaps(LOGPIXELSY),72),0,0,0,FW_NORMAL,0,0,0,GB2312_CHARSET,OUT_STROKE_PRECIS,CLIP_STROKE_PRECIS,DRAFT_QUALITY,VARIABLE_PITCH|FF_SWISS,_T("MS Serif"));//25为字体大小

pDC->SelectObject(&font);//设置字体

DrawRect.right = DrawRect.right - 100;

DrawRect.top = DrawRect.top + 180;

pDC->DrawText(strDate,&DrawRect,DT_RIGHT|DT_TOP|DT_SINGLELINE);//将文字绘出来

pDC->MoveTo(DrawRect.left,DrawRect.top+100);

pDC->LineTo(nWidth,DrawRect.top+100);

font.DeleteObject();

font.CreateFont(-MulDiv(12,-pDC->GetDeviceCaps(LOGPIXELSY),72),0,0,0,FW_NORMAL,0,0,0,GB2312_CHARSET,OUT_STROKE_PRECIS,CLIP_STROKE_PRECIS,DRAFT_QUALITY,VARIABLE_PITCH|FF_SWISS,_T("MS Serif"));

pDC->SelectObject(&font);

DrawRect.top = DrawRect.top+150;

pDC->DrawText("ID:"+str1[0],&DrawRect,DT_LEFT|DT_TOP|DT_SINGLELINE);//其中DT_LEFT表示左对齐

DrawRect.top = DrawRect.top+150;

pDC->DrawText("Name:"+str1[1],&DrawRect,DT_LEFT|DT_TOP|DT_SINGLELINE);

DrawRect.top = DrawRect.top+150;

pDC->DrawText("RadiotherapyNumber:"+str1[2],&DrawRect,DT_LEFT|DT_TOP|DT_SINGLELINE);

DrawRect.top = DrawRect.top+150;

pDC->DrawText("Age:"+str1[3],&DrawRect,DT_LEFT|DT_TOP|DT_SINGLELINE);

DrawRect.top = DrawRect.top+150;

pDC->DrawText("Sex:"+str1[4],&DrawRect,DT_LEFT|DT_TOP|DT_SINGLELINE);

DrawRect.top = DrawRect.top+150;

pDC->DrawText("Time:"+str1[5],&DrawRect,DT_LEFT|DT_TOP|DT_SINGLELINE);

DrawRect.top = DrawRect.top+150;

pDC->DrawText("Field:"+str1[6],&DrawRect,DT_LEFT|DT_TOP|DT_SINGLELINE);

DrawRect.top = DrawRect.top+150;

pDC->DrawText("Remarks:"+str1[7],&DrawRect,DT_LEFT|DT_TOP|DT_SINGLELINE);

pDC->MoveTo(DrawRect.left-100,DrawRect.top+150);

pDC->LineTo(nWidth,DrawRect.top+150);

pDC->SelectObject(oldfont);

//------------------------------------------------------------------------------------------------------------------

//以下为显示图片

// ::StretchBlt(pDC->m_hDC,DrawRect.left+100,nHeight/2,

// DrawRect.right - DrawRect.left-200,(float)nScaledHeight*((float)((float)DrawRect.right - (float)DrawRect.left - 100.00)/(float)nScaledWidth),

// dcMem,0,0,bitmap.bmWidth,bitmap.bmHeight,SRCCOPY);

// //StretchBlt的第二个和第三个参数可以调整图片的位置,第四个和第五个参数可以调整图片的大小

// ::SelectObject(dcMem,hOldBmp);

// ::DeleteDC(dcMem);

// ::DeleteObject(hBitmap);

//--------------------------------------------------------图片---------------------------------------------------------

DrawRect.top = DrawRect.top+150;

for(int i = 0; i < imgPath.size(); i++)

{

imgPath[i] = imgPath[i].Left(imgPath[i].GetLength()-3);

imgPath[i]+= "bmp";

HBITMAP hBitmap = (HBITMAP)LoadImage(NULL,g_curDirectoryPath + "res\\backupsFile\\image1\\"+deleteFileName+"\\"+imgPath[i], IMAGE_BITMAP,0, 0, LR_CREATEDIBSECTION |LR_DEFAULTSIZE | LR_LOADFROMFILE);

//修改后缀(改回JPG)

imgPath[i] = imgPath[i].Left(imgPath[i].GetLength()-3);

imgPath[i]+= "JPG";

BITMAP bitmap;

::GetObject(hBitmap,sizeof(BITMAP),&bitmap);

double dScale=(double)m_cxWidth/bitmap.bmWidth;

int nScaledWidth=m_cxWidth;

int nScaledHeight=(int)(bitmap.bmHeight*dScale);

HDC dcMem;

dcMem=::CreateCompatibleDC(pDC->m_hDC);

HBITMAP hOldBmp=(HBITMAP)::SelectObject(dcMem,hBitmap);

//以下为显示图片

::StretchBlt(pDC->m_hDC,

DrawRect.left+100,                //x

DrawRect.top+150,                //y

bitmap.bmWidth,                  //w

bitmap.bmHeight,                  //h

dcMem,0,0,bitmap.bmWidth,bitmap.bmHeight,SRCCOPY);

//StretchBlt的第二个和第三个参数可以调整图片的位置,第四个和第五个参数可以调整图片的大小

::SelectObject(dcMem,hOldBmp);

::DeleteDC(dcMem);

::DeleteObject(hBitmap);

}

return TRUE;

}

//更新绘制区域

void CMy2DHotWireCuttingDlg::InvalidateRectControl(int id)

{

CRect moniRect;

GetDlgItem(id)->GetWindowRect(&moniRect);

ScreenToClient(moniRect);

InvalidateRect(moniRect);

UpdateWindow();

}

//--------------------------------------------------------文件------------------------------------------------------------

//保存为BMP图片

// void CMy2DHotWireCuttingDlg::Onmenusavebmp()

// {

// // TODO: 在此添加命令处理程序代码

// if (b_digitizerShow)

// {

// if(CorE)

// AfxMessageBox("Please drop out of the digitizer first");

// else

// AfxMessageBox("请先退出数字化仪输入");

// }

// else

// {

// int staticId;

// if (b_digitizerShow) 

// {

// staticId = IDC_STATIC_group;

// }

// else

// {

// staticId = IDC_STATIC_blockShow;

// }

// CRect imgRect;

// GetDlgItem(staticId)->GetWindowRect(&imgRect);

// ScreenToClient(imgRect);

// CString imgSavePath;    //保存路径

//

// BOOL isOpen = FALSE;        //是否打开(否则为保存) 

// CString filter = "文件 (*.bmp; *.png; *.jpg)|*.bmp;*.png;*.jpg||";  //文件过虑的类型 

// CFileDialog openFileDlg(FALSE, NULL, NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, NULL, NULL); 

// INT_PTR result = openFileDlg.DoModal(); 

// if(result == IDOK) { 

// imgSavePath = openFileDlg.GetPathName(); 

// } 

//

// m_pData.imageSave(imgSavePath,0,GetDlgItem(staticId)->GetDC(),imgRect);

// }

// }

//备份病人资料

void CMy2DHotWireCuttingDlg::Onmenubackupsdata()

{

// TODO: 在此添加命令处理程序代码

if (b_digitizerShow)

{

if(CorE)

AfxMessageBox("Please drop out of the digitizer first");

else

AfxMessageBox("请先退出数字化仪输入");

}

else

{

//--------------------------------------获取当前时间作为文件名-------------------------------------------

CString nowTime;

nowTime = m_pData.getNowTime();

//------------------------------------------------------------------------------------------------------

CString sourcePath, targetPath;

sourcePath = g_curDirectoryPath + "res\\backupsFile";                            //Դ·¾¶

targetPath = "C:\\Program Files\\TFY-backups\\"+nowTime;    //Ä¿±ê·¾¶

if(!PathIsDirectory(targetPath))      //´´½¨¿½±´Îļþ¼Ð 

CreateDirectory(targetPath,NULL);

//------------------------------------------------------------------------------------------------------

TCHAR szFilter[] = _T("bac(*.bac)|All files(*.*)|*.*||"); 

// 构造保存文件对话框 

CFileDialog fileDlg(FALSE, _T("bac"), nowTime, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter, this); 

CString strFilePath; 

copyFile(sourcePath, targetPath);    //拷贝备份文件

// 显示保存文件对话框 

if (IDOK == fileDlg.DoModal()) 

// 如果点击了文件对话框上的“保存”按钮,则将选择的文件路径显示到编辑框里 

strFilePath = fileDlg.GetPathName();   

CStdioFile* myFilebackups;

myFilebackups = new CStdioFile();

if(myFilebackups->Open(strFilePath,CFile::typeText|CFile::modeCreate|CFile::modeReadWrite))

{

myFilebackups->WriteString(nowTime);  //保存文件拷贝文件信息

myFilebackups->Close();

}

}

}

}

//导入病人资料

void CMy2DHotWireCuttingDlg::Onmenuimportdata()

{

// TODO: 在此添加命令处理程序代码if (b_digitizerShow)

if(b_digitizerShow)

{

if(CorE)

AfxMessageBox("Please drop out of the digitizer first");

else

AfxMessageBox("请先退出数字化仪输入");

}

else

{

CString strFile = _T(""); 

CString sourcePath, targetPath;

sourcePath = "C:\\Program Files\\TFY-backups\\";            //源路径

targetPath = g_curDirectoryPath + "\\res\\backupsFile";    //目标路径

char path[MAX_PATH];

GetModuleFileName(NULL,path,1000);    //保存默认路径

CFileDialog dlgFile(TRUE, NULL, NULL, OFN_HIDEREADONLY, _T("Describe Files (*.bac)|*.bac"), NULL); 

currentPath.Format("%s",path);

targetPath = currentPath.Left(currentPath.GetLength()-20)+"\\res\\backupsFile";

if (dlgFile.DoModal()) 

strFile = dlgFile.GetPathName();

CStdioFile* myFileload;

myFileload = new CStdioFile();

if(myFileload->Open(strFile,CFile::modeRead))

{

//SetCurrentDirectory(path);    //恢复路径

CString loadFile;

myFileload->SeekToBegin();

myFileload->ReadString(loadFile);

copyFile(sourcePath+loadFile, targetPath);    //导入备份文件

if(CorE)

AfxMessageBox("copy Complete");

else

AfxMessageBox("拷贝完成");

myFileload->Close();

}

}

}

}

//打印

void CMy2DHotWireCuttingDlg::Onmenuprintf()

{

// TODO: 在此添加命令处理程序代码

if (b_digitizerShow)

{

if(CorE)

AfxMessageBox("Please drop out of the digitizer first");

else

AfxMessageBox("请先退出数字化仪输入");

}

else

{

if (printfPath == "")

{

if(CorE)

AfxMessageBox("Please choose a picture that needs to be printed");

else

AfxMessageBox("请选择需要打印的图片");

}

else

{

m_printf.setPrintfPath(printfPath,blockPath);

m_printf.DoModal();

}

}

}

//检测本机是否有打印机

void CMy2DHotWireCuttingDlg::ergodicPrint()

{

DWORD Flags = PRINTER_ENUM_FAVORITE |PRINTER_ENUM_LOCAL;

DWORD cbBuf;

DWORD pcReturned ;

CString str;

DWORD Level = 2;

TCHAR Name[500]={0} ;

::EnumPrinters(Flags,

Name,

Level,

NULL,

0,

&cbBuf, //需要多少内存

&pcReturned) ;

const LPPRINTER_INFO_2 pPrinterEnum = (LPPRINTER_INFO_2)LocalAlloc(LPTR, cbBuf + 4) ;

if(!pPrinterEnum)

{

str.Format("error is %d",GetLastError());

MessageBox(str,0,0);

}

if(!EnumPrinters(

Flags,

Name,

Level,

(LPBYTE)pPrinterEnum,

cbBuf,

&cbBuf,

&pcReturned)

)

{

str.Format("error is %d",::GetLastError());

MessageBox(str,0,0);

return ;

}

printSize.Format("%d",pcReturned);

LocalFree(pPrinterEnum);

}

//退出

void CMy2DHotWireCuttingDlg::Onmenuexit()

{

// TODO: 在此添加命令处理程序代码

m_mainInterface.clearNoCutImg();

KillTimer(1);

exit(1);

}

//--------------------------------------------------------病人资料------------------------------------------------------------

//添加记录

void CMy2DHotWireCuttingDlg::Onmenuaddpatientdata()

{

// TODO: 在此添加命令处理程序代码

if (b_digitizerShow)

{

if(CorE)

AfxMessageBox("Please drop out of the digitizer first");

else

AfxMessageBox("请先退出数字化仪输入");

}

else

{

m_addPatienData.setpatientType(0);

m_addPatienData.DoModal();

if (m_addPatienData.getaddPationDataExit())

{

for (int i = 0; i < 8; i++)

{

str1.push_back("");

}

getRecordsData();

//updateOneRecordsData(0,1);

}

}

}

//删除记录

void CMy2DHotWireCuttingDlg::Onmenudeletepatientdata()

{

// TODO: 在此添加命令处理程序代码

if (b_digitizerShow)

{

if(CorE)

AfxMessageBox("Please drop out of the digitizer first");

else

AfxMessageBox("请先退出数字化仪输入");

}

else

{

DeleteFile(g_curDirectoryPath + "res\\backupsFile\\records\\"+deleteFileName+".xml");

if(deleteFileName != "")

{

DeleteFolder(g_curDirectoryPath + "res\\backupsFile\\image\\"+deleteFileName+"\\");

DeleteFolder(g_curDirectoryPath + "res\\backupsFile\\image1\\"+deleteFileName+"\\");

DeleteFolder(g_curDirectoryPath + "res\\backupsFile\\image2\\"+deleteFileName+"\\");

DeleteFolder(g_curDirectoryPath + "res\\backupsFile\\blockData\\"+deleteFileName+"\\");

DeleteFolder(g_curDirectoryPath + "res\\backupsFile\\blockPos\\"+deleteFileName+"\\");

}

POSITION pos = m_list_patientData.GetFirstSelectedItemPosition();

int idx = m_list_patientData.GetNextSelectedItem(pos);

while (idx != -1){

LVITEM lvi;

lvi.iItem = idx;

lvi.iSubItem = 0;

lvi.mask = LVIF_IMAGE;

m_list_patientData.DeleteItem(idx);

idx = m_list_patientData.GetNextSelectedItem(pos);

}

//需要先排序,再重绘,否则从中间删除后该区域会空白,后面的记录不会自动上移

m_list_patientData.Arrange(LVA_DEFAULT);

m_list_patientData.RedrawItems(0, m_list_patientData.GetItemCount());

}

}

//修改记录

void CMy2DHotWireCuttingDlg::Onmenurevispatientdata()

{

// TODO: 在此添加命令处理程序代码

if (b_digitizerShow)

{

if(CorE)

AfxMessageBox("Please drop out of the digitizer first");

else

AfxMessageBox("请先退出数字化仪输入");

}

else

{

m_addPatienData.setpatientType(1);

m_addPatienData.setQuerypatientData(m_patientQD);

m_addPatienData.DoModal();

if (m_addPatienData.getaddPationDataExit())

{

updateOneRecordsData(clickedListId,0);

}

}

}

//向前浏览

void CMy2DHotWireCuttingDlg::Onmenuforwardlook()

{

//TODO: 在此添加命令处理程序代码

if (b_digitizerShow)

{

if(CorE)

AfxMessageBox("Please drop out of the digitizer first");

else

AfxMessageBox("请先退出数字化仪输入");

}

else

{

for(int i=0; i< m_list_patientData.GetItemCount(); i++)

{

if( m_list_patientData.GetItemState(i, LVIS_SELECTED) == LVIS_SELECTED )

{

imgIndex = i;

}

}

if (m_FileList.size() > 0)

{

if (imgIndex > 0)

imgIndex--;

else

imgIndex = m_FileList.size()-2;

for (int i = 0; i < m_FileList.size()-1; i++)

{

if (i != imgIndex)

m_list_patientData.SetItemState(i, 0, LVIS_SELECTED|LVIS_FOCUSED);

}

}

m_list_patientData.SetItemState(imgIndex, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);

}

}

}

//向后浏览

void CMy2DHotWireCuttingDlg::Onmenubackwardlook()

{

// TODO: 在此添加命令处理程序代码

if (b_digitizerShow)

{

if(CorE)

AfxMessageBox("Please drop out of the digitizer first");

else

AfxMessageBox("请先退出数字化仪输入");

}

else

{

for(int i=0; i< m_list_patientData.GetItemCount(); i++)

{

if( m_list_patientData.GetItemState(i, LVIS_SELECTED) == LVIS_SELECTED )

{

imgIndex = i;

}

}

if (m_FileList.size() > 0)

{

if (imgIndex < m_FileList.size()-2)

imgIndex++;

else

imgIndex = 0;

for (int i = 0; i < m_FileList.size()-1; i++)

{

if (i != imgIndex)

m_list_patientData.SetItemState(i, 0, LVIS_SELECTED|LVIS_FOCUSED);

}

}

m_list_patientData.SetItemState(imgIndex, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);

}

}

}

//--------------------------------------------------------输入------------------------------------------------------------

//文件输入

void CMy2DHotWireCuttingDlg::Onmenufileimport()

{

if(deleteFileName == "")

{

if(CorE)

AfxMessageBox("Please select patient.");

else

AfxMessageBox("请选择病人");

return;

}

bool flag=false;

fPoint coordinate;

fPoint printCoordinate;

CString strPath;

BOOL isOpen = TRUE;        //是否打开(否则为保存)   

CString defaultDir = _T("res");  //默认打开的文件路径   

CString fileName;        //默认打开的文件名   

CString filter = "blk(*.blk)|*.blk|dcm(*.dcm)|*.dcm||";  //文件过虑的类型   

// TODO: 在此添加命令处理程序代码

if (b_digitizerShow)

{

if(CorE)

AfxMessageBox("Please drop out of the digitizer first");

else

AfxMessageBox("请先退出数字化仪输入");

}

else

{

CFileDialog openFileDlg(isOpen,NULL, defaultDir+ "\\*.dcm" +fileName, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, filter, NULL); 

INT_PTR result = openFileDlg.DoModal();

ifstream fin;

if (result == IDOK) 

{   

string str;

vector<string> lines1;

vector<float> vec_coor;

int lineCount;

int begin=0;

float parameter = 0.125;

std::size_t startpos,endpos;

fileName = openFileDlg.GetPathName(); 

fileName.Replace("\\","/"); 

switch (openFileDlg.m_ofn.nFilterIndex) 

case 2: 

b_showBlkImage=false;

filter = "dcm"; 

//m_loadDCM.dcmStringPath(fileName);

//m_loadDCM.DoModal();

//readDcmImage(fileName);

if(readRtImage(fileName))

{

fin.open("res\\blockData.txt");

while(getline(fin,str))

{

vector<float>().swap(vec_coor);

startpos = str.find("[");

endpos  = str.find("]") - startpos;

if(startpos!=string::npos)

{

//lines1.push_back(str);

float parameter = 0.125;

while(endpos != string::npos)

{

str = str.substr(startpos + 1, endpos);

if(str=="")

break;

startpos = str.find("\\");

if(startpos == string::npos)

startpos = str.find("]");

vec_coor.push_back(atof(str.substr(0,startpos).c_str()));

startpos = str.substr(0,startpos).length();

endpos = str.find("]");

}

str="ok";//开始要对数组里的数据进行处理了

//std::string str_x=str1.substr(0,pos2);

//coordinate.x = (atof(str_x.c_str())+g_posShowCenter.x) / parameter;

}

}

//lineCount = lines1.size();

//for(int i = 0; i < lineCount; i++)

//{

//}

}

else

{

AfxMessageBox("这个不是RT Plan文件");

}

break; 

case 1:

b_saveblkimage = false;

blkImageDatas.clear();

g_savePrintBlockPos.clear();

blkcoordinate.clear();

g_printblkcoordinate.clear();

filter = "blk"; 

b_showBlkImage=true;

strPath = openFileDlg.GetPathName();

string sPath = strPath.GetBuffer(strPath.GetLength() + 1);

string str1("oint");

string str2("Contour");

vector<int> record;

lines1.clear();

record.clear();

fin.open(sPath);

while(getline(fin,str))

{

std::size_t pos1=str.find(str1);

if(pos1!=string::npos)

{

lines1.push_back(str);

}

}

lineCount=lines1.size();

for(int i=0;i<lineCount;i++)

{

begin=lines1.at(i).find(str2);

if(begin==string::npos)

{

std::size_t pos2= lines1.at(i).find("(");

std::string str3=lines1.at(i).substr(pos2+1);

pos2=str3.find(",");

std::string str_x=str3.substr(0,pos2);

coordinate.x=(atof(str_x.c_str())+g_posShowCenter.x) / parameter;

printCoordinate.x = (atof(str_x.c_str())+g_posShowCenter.x) * 23.622;

std::size_t pos3=str3.find(")");

std::string str_y=str3.substr(pos2+1,pos3-pos2-1);

coordinate.y=(atof(str_y.c_str())+g_posShowCenter.y) / parameter;

printCoordinate.y = (atof(str_y.c_str())+g_posShowCenter.y) * 23.622;

blkcoordinate.push_back(coordinate);

g_printblkcoordinate.push_back(printCoordinate);

}

else

{

if(record.size()>0)

{

blkImageDatas.push_back(blkcoordinate);

g_savePrintBlockPos.push_back(g_printblkcoordinate);

blkcoordinate.clear();

g_printblkcoordinate.clear();

}

else

record.push_back(1);

}

}

if(record.size()>0)

{

blkImageDatas.push_back(blkcoordinate);

g_savePrintBlockPos.push_back(g_printblkcoordinate);

blkcoordinate.clear();

record.clear();

}

fin.clear();

showBlkImage();

break;

// USES_CONVERSION; 

// char *file = T2A(fileName); 

// char *filterCH = T2A(filter);   

//else

// b_blkShow = !b_blkShow;

fin.close();

//m_loadDCM.dcmStringPath("res\\RD.yyyYKL.Dose_BEAM_2.dcm");

updateListImg();

}

//}

}

std::vector<cv::Mat> CMy2DHotWireCuttingDlg::GetImageFromDcmDataSet(DicomImage* dcmImage)

{

std::vector<cv::Mat> output_img;              //输出图像向量 

int framecount(dcmImage->getFrameCount()); //获取这个文件包含的图像的帧数 

for (int k = 0; k<framecount; k++)

{

unsigned char *pixelData = (unsigned char*)(dcmImage->getOutputData(8, k, 0)); //获得8位的图像数据指针   

if (pixelData != NULL)

{

int m_height = dcmImage->getHeight();

int m_width = dcmImage->getWidth();

cout << "高度:" << m_height << ",长度" << m_width << endl;

if (3 == Img_bitCount)

{

cv::Mat dst2(m_height, m_width, CV_8UC3, cv::Scalar::all(0));

for (int i = 0; i < m_height; i++)

{

for (int j = 0; j < m_width; j++)

{

dst2.at<cv::Vec3b>(i, j)[0] = *(pixelData + i*m_width * 3 + j * 3 + 2);  //B channel   

dst2.at<cv::Vec3b>(i, j)[1] = *(pixelData + i*m_width * 3 + j * 3 + 1);  //G channel   

dst2.at<cv::Vec3b>(i, j)[2] = *(pixelData + i*m_width * 3 + j * 3);      //R channel   

}

}

output_img.push_back(dst2);

}

else if (1 == Img_bitCount)

{

cv::Mat dst2(m_height, m_width, CV_8UC1, cv::Scalar::all(0));

uchar* data = nullptr;

for (int i = 0; i < m_height; i++)

{

data = dst2.ptr<uchar>(i);

for (int j = 0; j < m_width; j++)

{

data[j] = *(pixelData + i*m_width + j);

}

}

output_img.push_back(dst2);

cv::imshow("image", dst2);

cv::waitKey(0);

}

}

}

return output_img;

}

void CMy2DHotWireCuttingDlg::readDcmImage(CString file_path)

{

DicomImage *img=new DicomImage(file_path);

if (img->getStatus() == EIS_Normal && img != NULL)

{

if (img->isMonochrome())

{

int nWidth = img->getWidth();            //获得图像宽度 

int nHeight = img->getHeight();          //获得图像高度 

Uint16 *pixelData = (Uint16*)(img->getOutputData(16));  //获得16位的图像数据指针 

std::cout << nWidth << ", " << nHeight << std::endl;

if (pixelData != NULL)

{

cv::Mat dst2(nWidth, nHeight, CV_16UC1, cv::Scalar::all(0));

unsigned short* data = nullptr;

for (int i = 0; i < nHeight; i++)

{

data = dst2.ptr<unsigned short>(i);  //取得每一行的头指针 也可使用dst2.at<unsigned short>(i, j) = ? 

for (int j = 0; j < nWidth; j++)

{

*data++ = pixelData[i*nWidth + j];

}

}

cv::imshow("image2", dst2);

}

}

}

}

bool CMy2DHotWireCuttingDlg::readRtImage(CString file_path)

{

bool result = false;

DcmFileFormat fileformat;

OFCondition oc;

DcmDataset *dataset;

E_TransferSyntax xfer;

DcmSequenceOfItems *sequence;

DcmTag dcmTag;

Uint16 element;

std::filebuf fb;

fb.open("res\\blockData.txt",std::ios::out);

std::ostream os(&fb);

oc = fileformat.loadFile(file_path.GetBuffer()); //读取Dicom文件

if(oc.good()) //如果成功的话

{

dataset = fileformat.getDataset(); //得到Dicom的数据集

xfer = dataset->getOriginalXfer(); //得到传输语法

dataset->findAndGetSequence(DCM_BeamSequence,sequence);

if(sequence !=NULL)

{

DcmStack stack,stack2;

OFBool first = OFTrue;

while(sequence->nextObject(stack,first).good())

{

DcmItem *ditem = OFstatic_cast(DcmItem *,stack.top());

if(ditem !=NULL)

{

dcmTag = ditem->getTag();

element = dcmTag.getElement();

if(element == 0x0106)

{

ditem->print(os);

result = true;

}

}

}

}

}

fileformat.clear();

return result;

}

void CMy2DHotWireCuttingDlg::showBlkImage()

{

//if(b_blkShow)

//{

if(deleteFileName == "")

{

if(CorE)

AfxMessageBox("Please select patient.");

else

AfxMessageBox("请选择病人");

// b_blkShow = false;

}

else

{

GetDlgItem(IDC_STATIC_group)->ShowWindow(SW_SHOW);

//m_digitizerInput->DoModal();

CRect groupRect;

GetDlgItem(IDC_STATIC_group)->GetWindowRect(&groupRect);

ClientToScreen(groupRect);

//¸Äһϣ¬Óñê×¼µµ¿éÀ´ÏÔʾBLK£¬ÕâÑù¿ÉÒÔ¿ª·ÅʽÉèÖÃÔ´Íоà

m_standardBlock.setSaveFileName(deleteFileName);

m_standardBlock.DoModal();

//m_digitizerInput->ShowWindow(SW_SHOW);

//m_debugging.dlg->ShowWindow(SW_HIDE);

//GetDlgItem(IDC_LIST_patienData)->ShowWindow(SW_HIDE);

}

//}

}

//数据字化仪输入

void CMy2DHotWireCuttingDlg::OnmenuDigitizerimport()

{

// TODO: 在此添加命令处理程序代码

// b_digitizerShow = !b_digitizerShow;

if(b_digitizerShow == false)

{

if(deleteFileName == "")

{

if(CorE)

AfxMessageBox("Please select patient");

else

AfxMessageBox("请选择病人");

b_digitizerShow = false;

return;

}

else

{

GetDlgItem(IDC_STATIC_group)->ShowWindow(SW_SHOW);

//m_digitizerInput->DoModal();

CRect groupRect;

GetDlgItem(IDC_STATIC_group)->GetWindowRect(&groupRect);

ClientToScreen(groupRect);

m_digitizerInput->ShowWindow(SW_SHOW);

m_digitizerInputData.DoModal();

m_digitizerInput->setSaveFileName(deleteFileName);

m_digitizerInput->setInputData(m_digitizerInputData.getInputData());

m_digitizerInput->setPos(groupRect.left,groupRect.top);

m_digitizerInput->openPort();

g_closeDigitizerPort = false;

m_debugging.dlg->ShowWindow(SW_HIDE);

GetDlgItem(IDC_LIST_patienData)->ShowWindow(SW_HIDE);

}

b_digitizerShow = true;

}

else

{

if(g_closeDigitizerPort == false)

{

  m_digitizerInput->ClosePort();

  m_digitizerInput->ShowWindow(SW_HIDE);

}

g_closeDigitizerPort = true;

if (m_tab.GetCurSel() == 2)

{

m_debugging.dlg->ShowWindow(SW_SHOW);

}

else

{

GetDlgItem(IDC_LIST_patienData)->ShowWindow(SW_SHOW);

GetDlgItem(IDC_STATIC_group)->ShowWindow(SW_HIDE);

}

updateListImg();

b_digitizerShow = false;

}

}

//标准挡块

void CMy2DHotWireCuttingDlg::Onmenustandardblock()

{

// TODO: 在此添加命令程序代码

b_showBlkImage=false;

if (b_digitizerShow)

{

if(CorE)

AfxMessageBox("Please drop out of the digitizer first");

else

AfxMessageBox("请先退出数字化仪输入");

}

else

{

if(deleteFileName == "")

{

if(CorE)

AfxMessageBox("Please select patient.");

else

AfxMessageBox("请选择病人");

}

else

{

m_standardBlock.setSaveFileName(deleteFileName);

m_standardBlock.DoModal();

updateListImg();

}

}

}

//--------------------------------------------------------配置------------------------------------------------------------

//参数设置

void CMy2DHotWireCuttingDlg::Onmenuset()

{

// TODO: 在此添加命令处理程序代码

if (b_digitizerShow)

{

if(CorE)

AfxMessageBox("Please drop out of the digitizer first");

else

AfxMessageBox("请先退出数字化仪输入");

}

else

m_parametersSet.DoModal();

}

//--------------------------------------------------------ϵͳ------------------------------------------------------------

//ϵͳ¹ÜÀíÔ±

void CMy2DHotWireCuttingDlg::OnmenuAdministrators()

{

// TODO: 在此添加命令处理程序代码

if (b_digitizerShow)

{

if(CorE)

AfxMessageBox("Please drop out of the digitizer first");

else

AfxMessageBox("请先退出数字化仪输入");

}

else

m_loding.DoModal();

}

//注销

void CMy2DHotWireCuttingDlg::OnmenuCancellation()

{

// TODO: 在此添加命令处理程序代码

AfxMessageBox("logout");

}

//修改管理员密码

void CMy2DHotWireCuttingDlg::Onmenurevisadministrators()

{

// TODO: 在此添加命令处理程序代码

AfxMessageBox("modify password of administrator ");

}

//--------------------------------------------------------帮助------------------------------------------------------------

//注册

void CMy2DHotWireCuttingDlg::Onmenuregister()

{

// TODO: 在此添加命令处理程序代码

if (b_digitizerShow)

{

if(CorE)

AfxMessageBox("Please drop out of the digitizer first");

else

AfxMessageBox("请先退出数字化仪输入");

}

else

{

m_addregister.edit_ActivationCode = "";

m_addregister.DoModal();

}

// srand(time(NULL));

// int x=rand()%47;

// m_debugging.dlg->setEllipseRGB(x,255,0);

}

//Êý×Ö»¯ÒDzâÊÔ

void CMy2DHotWireCuttingDlg::OnmenuDigitizertest()

{

// TODO: ÔÚ´ËÌí¼ÓÃüÁî´¦Àí³ÌÐò´úÂë

if (b_digitizerShow)

{

if(CorE)

AfxMessageBox("Please drop out of the digitizer first");

else

AfxMessageBox("请先退出数字化仪输入");

}

else

m_digitizerSet.DoModal();

}

//关于

void CMy2DHotWireCuttingDlg::Onmenuabout()

{

// TODO: 在此添加命令处理程序代码

AfxMessageBox("关于");

}

//tab面板

void CMy2DHotWireCuttingDlg::OnTcnSelchangeTab1(NMHDR *pNMHDR, LRESULT *pResult)

{

// TODO: 在此添加控件通知处理程序代码

*pResult = 0;

CRect tabRect;    // 标签控件客户区的Rect 

// 获取标签控件客户区Rect,并对其调整,以适合放置标签页 

m_tab.GetClientRect(&tabRect); 

tabRect.left += 1; 

tabRect.right -= 1; 

tabRect.top += 25; 

tabRect.bottom -= 1; 

switch (m_tab.GetCurSel()) 

// 如果标签控件当前选择标签为“主界面”,则显示zhujiemianDlg对话框,隐藏bingrenchaxunDlg/tiaoshiDla对话框 

case 0: 

// m_debugging.endTimer();

m_mainInterface.OnInitDialog();

if (deleteFileName != "" && loadMoveFilePath != "")

m_mainInterface.loadMoveData(g_curDirectoryPath + "res\\backupsFile\\image1\\"+deleteFileName+"\\" + loadMoveFilePath,m_parametersSet.getFileName(),g_curDirectoryPath + "res\\backupsFile\\blockData\\"+deleteFileName+"\\" + loadMoveFilePath);

m_mainInterface.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_SHOWWINDOW); 

m_patienQuery.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_HIDEWINDOW); 

m_debugging.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_HIDEWINDOW);

//----------------------------------------------------调试界面隐藏-------------------------------------------------------------

if(!b_digitizerShow)

{

m_debugging.dlg->ShowWindow(SW_HIDE);

GetDlgItem(IDC_LIST_patienData)->ShowWindow(SW_SHOW);

GetDlgItem(IDC_STATIC_group)->ShowWindow(SW_HIDE);

}

break;

case 1: 

//m_mainInterface.endTimer();

//m_debugging.endTimer();

m_mainInterface.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_HIDEWINDOW); 

m_patienQuery.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_SHOWWINDOW); 

m_debugging.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_HIDEWINDOW);

//----------------------------------------------------调试界面隐藏-------------------------------------------------------------

if(!b_digitizerShow)

{

m_debugging.dlg->ShowWindow(SW_HIDE);

GetDlgItem(IDC_LIST_patienData)->ShowWindow(SW_SHOW);

GetDlgItem(IDC_STATIC_group)->ShowWindow(SW_HIDE);

}

break; 

case 2: 

//m_mainInterface.endTimer();

m_debugging.OnInitDialog();

m_mainInterface.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_HIDEWINDOW); 

m_patienQuery.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_HIDEWINDOW); 

m_debugging.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_SHOWWINDOW);

//----------------------------------------------------调试界面显示-------------------------------------------------------------

if(!b_digitizerShow)

{

m_debugging.dlg->ShowWindow(SW_SHOW);

m_debugging.startTimer();

m_digitizerInput->ShowWindow(SW_HIDE);

GetDlgItem(IDC_LIST_patienData)->ShowWindow(SW_HIDE);

GetDlgItem(IDC_STATIC_group)->ShowWindow(SW_SHOW);

}

break; 

default: 

break; 

}

//病人列表选择

void CMy2DHotWireCuttingDlg::OnLvnItemchangedListpatiendata(NMHDR *pNMHDR, LRESULT *pResult)

{

//LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);

// TODO: 在此添加控件通知处理程序代码

NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;

if (b_isSetup)

{

if (pNMListView->iItem != -1)

{

deleteFileName = m_list_patientData.GetItemText(pNMListView->iItem,5);

g_deleteFileName=deleteFileName;

updataRecordsData(g_curDirectoryPath+"res\\backupsFile\\records\\"+deleteFileName+".xml",1,1);

imgPath = m_pData.ScanDiskFile(g_curDirectoryPath+"res\\backupsFile\\image\\"+deleteFileName);

dataPath = m_pData.ScanDiskFile(g_curDirectoryPath+"res\\backupsFile\\blockData\\"+deleteFileName);

clickedListId = pNMListView->iItem;              //记录选择的列表

//-----------------------------------------------------添加列表图片显示-------------------------------------------------------------

m_list_Icon.DeleteAllItems();                    //清空图片列表

if(m_il.m_hImageList!=NULL)

{

int iImageCount=m_il.GetImageCount();

for(int i=0;i<iImageCount;i++)

{

m_il.Remove(0);

}

}else

{

m_il.Create(128,128,ILC_COLOR32|ILC_MASK,10,2);    //初始化图片列表图片容器

}

for (int i = 0; i < imgPath.size(); i++)        //添加图片

{

addIcon(g_curDirectoryPath+"res\\backupsFile\\image\\"+deleteFileName+"\\"+imgPath[i],i);

}

m_list_Icon.SetImageList(&m_il,LVSIL_NORMAL);      //设置列表显示图片

for (int i = 0; i < imgPath.size(); i++)        //显示图片

{

showIcon(i);

}

//---------------------------------------------------------------------------------------------------------------------------------

}

}

*pResult = 0;

}

//更新列表图片

void CMy2DHotWireCuttingDlg::updateListImg()

{

deleteFileName = m_list_patientData.GetItemText(clickedListId,5);

g_deleteFileName=deleteFileName;

/////////////////////////////////////////////////////////////////

if(m_il.m_hImageList!=NULL)

{

int iImageCount=m_il.GetImageCount();

for(int i=0;i<iImageCount;i++)

{

m_il.Remove(0);

}

}else

{

m_il.Create(128,128,ILC_COLOR32|ILC_MASK,10,2);    //³õʼ»¯Í¼Æ¬ÁбíͼƬÈÝÆ÷

}

/////////////////////////////////////////////////////////////////

if(!deleteFileName.IsEmpty())

{

updataRecordsData(g_curDirectoryPath + "res\\backupsFile\\records\\"+deleteFileName+".xml",1,1);

imgPath = m_pData.ScanDiskFile(g_curDirectoryPath + "res\\backupsFile\\image\\"+deleteFileName);

dataPath = m_pData.ScanDiskFile(g_curDirectoryPath + "res\\backupsFile\\blockData\\"+deleteFileName);

m_list_Icon.DeleteAllItems();                    //清空图片列表

for (int i = 0; i < imgPath.size(); i++)        //添加图片

{

addIcon(g_curDirectoryPath+ "res\\backupsFile\\image\\"+deleteFileName+"\\"+imgPath[i],i);

}

m_list_Icon.SetImageList(&m_il,LVSIL_NORMAL);      //设置列表显示图片

for (int i = 0; i < imgPath.size(); i++)        //显示图片

{

showIcon(i);

}

m_il.Detach();

}

}

//档块列表选择

void CMy2DHotWireCuttingDlg::OnLvnItemchangedList3(NMHDR *pNMHDR, LRESULT *pResult)

{

//LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);

// TODO: 在此添加控件通知处理程序代码

NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;

if (pNMListView->iItem != -1)

{

loadMoveFilePath = imgPath[pNMListView->iItem].Left(imgPath[pNMListView->iItem].GetLength()-4);

loadMoveFilePath += ".bmp";

//------------------------------------------------------------挡块路径--------------------------------------------------------

blockFilePath = imgPath[pNMListView->iItem].Left(imgPath[pNMListView->iItem].GetLength()-4);

blockFilePath += ".xml";

blockPath  =g_curDirectoryPath+  "res\\backupsFile\\blockData\\"+deleteFileName+"\\" + blockFilePath;

//------------------------------------------------------------图片路径--------------------------------------------------------

//数据源图片

loadimgPath  = g_curDirectoryPath + "res\\backupsFile\\image1\\"+deleteFileName+"\\" + loadMoveFilePath;

//打印图片路径

printfPath = g_curDirectoryPath + "res\\backupsFile\\image2\\"+deleteFileName+"\\" + loadMoveFilePath;

m_mainInterface.loadMoveData(loadimgPath,m_parametersSet.getFileName(),blockPath);

//m_mainInterface.setstartCuting(false);

//b_AddCuting = false;

}

*pResult = 0;

}

DWORD WINAPI ThreadProcLoad(LPVOID lpParam)

{

threadInfoLoad *info = (threadInfoLoad*)lpParam;

if (!m_bExitThread)

{

// info->m_moveControl->loadMove(info->filePath);

m_bExitThread = true;

}

return 0;

}

//中文

void CMy2DHotWireCuttingDlg::Onchain()

{

// TODO: 在此添加命令处理程序代码

CorE = false;

m_debugging.setCorE(CorE);

m_mainInterface.setCorE(CorE);

m_patienQuery.setCorE(CorE);

m_addPatienData.setCorE(CorE);

m_parametersSet.setCorE(CorE);

m_loding.setCorE(CorE);

m_standardBlock.setCorE(CorE);

m_digitizerSet.setCorE(CorE);

m_addregister.setCorE(CorE);

m_blockShow->setCorE(CorE);

m_digitizerInput->setCorE(CorE);

m_digitizerInputData.setCorE(CorE);

SetWindowText("Create Technology 2DHotWireCutting");

TCITEM tcItem0;

tcItem0.mask = TCIF_TEXT;

tcItem0.pszText = "MainInterFace";

m_tab.SetItem(0, &tcItem0);

TCITEM tcItem1;

tcItem1.mask = TCIF_TEXT;

tcItem1.pszText = "PatientQuery";

m_tab.SetItem(1, &tcItem1);

TCITEM tcItem2;

tcItem2.mask = TCIF_TEXT;

tcItem2.pszText = "Debugging";

m_tab.SetItem(2, &tcItem2);

CRect tabRect;    // 标签控件客户区的Rect 

// 获取标签控件客户区Rect,并对其调整,以适合放置标签页 

m_tab.GetClientRect(&tabRect); 

tabRect.left += 1; 

tabRect.right -= 1; 

tabRect.top += 25; 

tabRect.bottom -= 1; 

switch (m_tab.GetCurSel()) 

// 如果标签控件当前选择标签为“主界面”,则显示zhujiemianDlg对话框,隐藏bingrenchaxunDlg/tiaoshiDla对话框 

case 0: 

m_mainInterface.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_SHOWWINDOW); 

m_patienQuery.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_HIDEWINDOW); 

m_debugging.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_HIDEWINDOW);

break;

case 1: 

m_mainInterface.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_HIDEWINDOW); 

m_patienQuery.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_SHOWWINDOW); 

m_debugging.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_HIDEWINDOW);

break; 

case 2: 

m_mainInterface.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_HIDEWINDOW); 

m_patienQuery.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_HIDEWINDOW); 

m_debugging.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_SHOWWINDOW);

break; 

default: 

break; 

//-----------------------------------------更新列表-----------------------------------------

LVCOLUMN lvc0;

lvc0.mask= LVCF_TEXT; 

lvc0.pszText="ID";

m_list_patientData.SetColumn(0,&lvc0);

LVCOLUMN lvc1;

lvc1.mask= LVCF_TEXT; 

lvc1.pszText="Name";

m_list_patientData.SetColumn(1,&lvc1);

LVCOLUMN lvc2;

lvc2.mask= LVCF_TEXT; 

lvc2.pszText="RadiotherapyNumber";

m_list_patientData.SetColumn(2,&lvc2);

LVCOLUMN lvc3;

lvc3.mask= LVCF_TEXT; 

lvc3.pszText="Age";

m_list_patientData.SetColumn(3,&lvc3);

LVCOLUMN lvc4;

lvc4.mask= LVCF_TEXT; 

lvc4.pszText="Sex";

m_list_patientData.SetColumn(4,&lvc4);

LVCOLUMN lvc5;

lvc5.mask= LVCF_TEXT; 

lvc5.pszText="Time";

m_list_patientData.SetColumn(5,&lvc5);

LVCOLUMN lvc6;

lvc6.mask= LVCF_TEXT;

lvc6.pszText="Field";

m_list_patientData.SetColumn(6,&lvc6);

LVCOLUMN lvc7;

lvc7.mask= LVCF_TEXT; 

lvc7.pszText="Remarks";

m_list_patientData.SetColumn(7,&lvc7);

m_toolbar.SetButtonText(0,"Add");

m_toolbar.SetButtonText(1,"Delete");

m_toolbar.SetButtonText(2,"Modify");

m_toolbar.SetButtonText(4,"Forward");

m_toolbar.SetButtonText(5,"Backwards");

m_toolbar.SetButtonText(7,"Digitizer");

m_toolbar.SetButtonText(8,"File");

m_toolbar.SetButtonText(9,"Standard");

m_toolbar.SetButtonText(11,"Set");

m_toolbar.SetButtonText(12,"´Print");

Invalidate();

UpdateWindow();

}

//英语

void CMy2DHotWireCuttingDlg::OnEnglish()

{

// TODO: 在此添加命令处理程序代码

CorE = true;

m_debugging.setCorE(CorE);

m_mainInterface.setCorE(CorE);

m_patienQuery.setCorE(CorE);

m_addPatienData.setCorE(CorE);

m_parametersSet.setCorE(CorE);

m_loding.setCorE(CorE);

m_standardBlock.setCorE(CorE);

m_digitizerSet.setCorE(CorE);

m_addregister.setCorE(CorE);

m_blockShow->setCorE(CorE);

m_digitizerInput->setCorE(CorE);

m_digitizerInputData.setCorE(CorE);

SetWindowText("HotWireCuttingSoftware");

TCITEM tcItem0;

tcItem0.mask = TCIF_TEXT;

tcItem0.pszText = "MainInterFace";

m_tab.SetItem(0, &tcItem0);

TCITEM tcItem1;

tcItem1.mask = TCIF_TEXT;

tcItem1.pszText = "Patien Search";

m_tab.SetItem(1, &tcItem1);

TCITEM tcItem2;

tcItem2.mask = TCIF_TEXT;

tcItem2.pszText = "Debugging";

m_tab.SetItem(2, &tcItem2);

CRect tabRect;    // 标签控件客户区的Rect 

// 获取标签控件客户区Rect,并对其调整,以适合放置标签页 

m_tab.GetClientRect(&tabRect); 

tabRect.left += 1; 

tabRect.right -= 1; 

tabRect.top += 25; 

tabRect.bottom -= 1; 

switch (m_tab.GetCurSel()) 

// 如果标签控件当前选择标签为“主界面”,则显示zhujiemianDlg对话框,隐藏bingrenchaxunDlg/tiaoshiDla对话框 

case 0: 

m_mainInterface.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_SHOWWINDOW); 

m_patienQuery.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_HIDEWINDOW); 

m_debugging.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_HIDEWINDOW);

break;

case 1: 

m_mainInterface.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_HIDEWINDOW); 

m_patienQuery.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_SHOWWINDOW); 

m_debugging.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_HIDEWINDOW);

break; 

case 2: 

m_mainInterface.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_HIDEWINDOW); 

m_patienQuery.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_HIDEWINDOW); 

m_debugging.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_SHOWWINDOW);

break; 

default: 

break; 

//--------------------------------------更新列表--------------------------------------------------

LVCOLUMN lvc0;

lvc0.mask= LVCF_TEXT; 

lvc0.pszText="ID";

m_list_patientData.SetColumn(0,&lvc0);

LVCOLUMN lvc1;

lvc1.mask= LVCF_TEXT; 

lvc1.pszText="Name";

m_list_patientData.SetColumn(1,&lvc1);

LVCOLUMN lvc2;

lvc2.mask= LVCF_TEXT; 

lvc2.pszText="Radiotherapy";

m_list_patientData.SetColumn(2,&lvc2);

LVCOLUMN lvc3;

lvc3.mask= LVCF_TEXT; 

lvc3.pszText="Age";

m_list_patientData.SetColumn(3,&lvc3);

LVCOLUMN lvc4;

lvc4.mask= LVCF_TEXT; 

lvc4.pszText="Sex";

m_list_patientData.SetColumn(4,&lvc4);

LVCOLUMN lvc5;

lvc5.mask= LVCF_TEXT; 

lvc5.pszText="Time";

m_list_patientData.SetColumn(5,&lvc5);

LVCOLUMN lvc6;

lvc6.mask= LVCF_TEXT;

lvc6.pszText="Field";

m_list_patientData.SetColumn(6,&lvc6);

LVCOLUMN lvc7;

lvc7.mask= LVCF_TEXT; 

lvc7.pszText="Remarks";

m_list_patientData.SetColumn(7,&lvc7);

m_toolbar.SetButtonText(0,"add");

m_toolbar.SetButtonText(1,"delet");

m_toolbar.SetButtonText(2,"modify");

m_toolbar.SetButtonText(4,"Navigate");

m_toolbar.SetButtonText(5,"Browse");

m_toolbar.SetButtonText(7,"Digitizer");

m_toolbar.SetButtonText(8,"file");

m_toolbar.SetButtonText(9,"standard");

m_toolbar.SetButtonText(11,"set");

m_toolbar.SetButtonText(12,"print");

}

//双击挡块

void CMy2DHotWireCuttingDlg::OnNMDblclkList3(NMHDR *pNMHDR, LRESULT *pResult)

{

//LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);

// TODO: 在此添加控件通知处理程序代码

NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;

if (pNMListView->iItem != -1)

{

GetDlgItem(IDC_STATIC_blockShow)->ShowWindow(SW_SHOW);

m_blockShow->setNameNumber(str1[1],str1[0]);

m_blockShow->laodImg(g_curDirectoryPath + "res\\backupsFile\\image\\"+deleteFileName+"\\"+imgPath[pNMListView->iItem]);

m_blockShow->laodData(g_curDirectoryPath + "res\\backupsFile\\blockData\\"+deleteFileName+"\\"+dataPath[pNMListView->iItem]);

m_blockShow->ShowWindow(SW_SHOW);

GetDlgItem(IDC_LIST_patienData)->ShowWindow(SW_HIDE);

GetDlgItem(IDC_STATIC_group)->ShowWindow(SW_HIDE);

GetDlgItem(IDC_LIST3)->ShowWindow(SW_HIDE);

}

*pResult = 0;

}

//计时器

void CMy2DHotWireCuttingDlg::OnTimer(UINT_PTR nIDEvent)

{

// TODO: 在此添加消息处理程序代码和/或调用默认值

switch(nIDEvent)

{

case  1:

if (m_blockShow->getblockShowExit())        //退出挡块放大

{

GetDlgItem(IDC_STATIC_blockShow)->ShowWindow(SW_HIDE);

GetDlgItem(IDC_LIST_patienData)->ShowWindow(SW_SHOW);

GetDlgItem(IDC_STATIC_group)->ShowWindow(SW_SHOW);

GetDlgItem(IDC_LIST3)->ShowWindow(SW_SHOW);

m_blockShow->setblockShowExit(false);

}

break;

case 2:

if(g_closeDigitizerPort)

  if(b_digitizerShow)

OnmenuDigitizerimport();

}

CDialogEx::OnTimer(nIDEvent);

}

//设置控件颜色

HBRUSH CMy2DHotWireCuttingDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)

{

HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);

// TODO:  在此更改 DC 的任何特性

// TODO:  如果默认的不是所需画笔,则返回另一个画笔

return hbr;

}

//捕获按键

BOOL CMy2DHotWireCuttingDlg::PreTranslateMessage(MSG* pMsg)

{

// TODO: 在此添加专用代码和/或调用基类

if (pMsg->hwnd == ::GetDlgItem(this->m_hWnd, IDC_LIST3))

{

switch(pMsg->wParam)

{

case VK_UP:

return TRUE;

break;

case VK_DOWN:

return TRUE;

break;

case VK_LEFT:

return TRUE;

break;

case VK_RIGHT:

return TRUE;

break;

}

}

if (pMsg->hwnd == ::GetDlgItem(this->m_hWnd, IDC_LIST_patienData))

{

switch(pMsg->wParam)

{

case VK_UP:

return TRUE;

break;

case VK_DOWN:

return TRUE;

break;

case VK_LEFT:

return TRUE;

break;

case VK_RIGHT:

return TRUE;

break;

case VK_ESCAPE:

return TRUE;

}

}

if (pMsg->message == WM_KEYDOWN)

{

g_finishCuttingFlag = false;

switch(pMsg->wParam)

{

case 87:

m_mainInterface.upImg();

drawBlockBk();

break;

case 83:

m_mainInterface.downImg();

drawBlockBk();

break;

case 65:

m_mainInterface.leftImg();

drawBlockBk();

break;

case 68:

m_mainInterface.rightImg();

drawBlockBk();

break;

case VK_ESCAPE:

return TRUE;

}

}

return CDialogEx::PreTranslateMessage(pMsg);

}

//鼠标按下

void CMy2DHotWireCuttingDlg::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)

{

// TODO: 在此添加消息处理程序代码和/或调用默认值

CDialogEx::OnKeyDown(nChar, nRepCnt, nFlags);

}

//图标列表拖动

void CMy2DHotWireCuttingDlg::OnLvnBegindragList3(NMHDR *pNMHDR, LRESULT *pResult)

{

//LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);

NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;

// TODO: 在此添加控件通知处理程序代码

*pResult = 0;

}

//鼠标左键按下

void CMy2DHotWireCuttingDlg::OnLButtonDown(UINT nFlags, CPoint point)

{

// TODO: 在此添加消息处理程序代码和/或调用默认值

CDialogEx::OnLButtonDown(nFlags, point);

}

//鼠标左键松开

void CMy2DHotWireCuttingDlg::OnLButtonUp(UINT nFlags, CPoint point)

{

// TODO: 在此添加消息处理程序代码和/或调用默认值

CDialogEx::OnLButtonUp(nFlags, point);

}

//鼠标移动

void CMy2DHotWireCuttingDlg::OnMouseMove(UINT nFlags, CPoint point)

{

// TODO: 在此添加消息处理程序代码和/或调用默认值

CDialogEx::OnMouseMove(nFlags, point);

}

//在list当款列表里面单击鼠标右键

void CMy2DHotWireCuttingDlg::OnNMRClickList3(NMHDR *pNMHDR, LRESULT *pResult)

{

//XSleep(1000);

LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);

// TODO: 在此添加控件通知处理程序代码

NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;

if(pNMListView->iItem != -1)

{

//currentIndex = pNMListView->iItem;

DWORD dwPos = GetMessagePos();

CPoint point( LOWORD(dwPos), HIWORD(dwPos) );

CMenu menu;

if(CorE)

VERIFY( menu.LoadMenu( IDR_MENU4 ) );

else

VERIFY( menu.LoadMenu( IDR_MENU2 ) );

CMenu* popup = menu.GetSubMenu(0);

ASSERT( popup != NULL );

popup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this );

//---------------------------------------------------------------------------------------------

b_listDrag = true;

loadMoveFilePath = imgPath[pNMListView->iItem].Left(imgPath[pNMListView->iItem].GetLength()-4);

loadMoveFilePath += ".bmp";

//------------------------------------------------------------挡块路径--------------------------------------------------------

CString blockFilePath;

blockFilePath = imgPath[pNMListView->iItem].Left(imgPath[pNMListView->iItem].GetLength()-4);

blockFilePath += ".xml";

blockPath  = g_curDirectoryPath + "res\\backupsFile\\blockData\\"+deleteFileName+"\\" + blockFilePath;

//------------------------------------------------------------图片路径--------------------------------------------------------

//数据源图片

CString loadimgPath;

loadimgPath  = g_curDirectoryPath + "res\\backupsFile\\image1\\"+deleteFileName+"\\" + loadMoveFilePath;

//打印图片路径

printfPath = g_curDirectoryPath + "res\\backupsFile\\image2\\"+deleteFileName+"\\" + loadMoveFilePath;

m_mainInterface.loadMoveData(loadimgPath,m_parametersSet.getFileName(),blockPath);

}

*pResult = 0;

}

//添加到切割

void CMy2DHotWireCuttingDlg::OnAddCuting()

{

// TODO: 在此添加命令处理程序代

g_finishCuttingFlag = false;

b_addCutingImgs = TRUE;

XSleep(100);

m_mainInterface.addImgShow();//这个是画图,画射野到泡沫里

XSleep(200);

//Sleep(200);    //等图片画完

m_mainInterface.rightImg();

m_mainInterface.setstartCuting(true);

drawBlockBk();

b_clearBlock = false;

b_AddCuting = true;

// Invalidate(0);

}

//删除图像列表的图标

void CMy2DHotWireCuttingDlg::OnDeleteIcon()

{

// TODO:代码还没写,以下是写关于删除图像列表的图标的代码

//取第几个不好取,但是是从0开始的。

//imgPath = m_pData.ScanDiskFile(g_curDirectoryPath+"res\\backupsFile\\image\\"+deleteFileName);

int deletepos = m_list_Icon.GetSelectionMark();

if(deleteFileName != "")

{

DeleteFile(g_curDirectoryPath + "res\\backupsFile\\image\\"+deleteFileName+"\\" + imgPath[deletepos]);

DeleteFile(g_curDirectoryPath + "res\\backupsFile\\image1\\"+deleteFileName+"\\" + imgPath[deletepos]);

DeleteFile(g_curDirectoryPath + "res\\backupsFile\\image2\\"+deleteFileName+"\\" + imgPath[deletepos]);

DeleteFile(g_curDirectoryPath + "res\\backupsFile\\blockData\\"+deleteFileName+"\\" + imgPath[deletepos]);

DeleteFile(g_curDirectoryPath + "res\\backupsFile\\blockPos\\"+deleteFileName+"\\" + imgPath[deletepos]);

}

m_list_Icon.DeleteItem(deletepos);

imgPath.erase(imgPath.begin() + deletepos);

}

//图片左右镜像

void CMy2DHotWireCuttingDlg::mirrorlRL(CString _srcPath,CString _dstPath)

{

Mat src = imread(_srcPath.GetBuffer(),CV_LOAD_IMAGE_UNCHANGED);   

Mat dst; 

flip(src, dst, 1); 

imwrite(_dstPath.GetBuffer(), dst); 

}

//图片上下镜像

void CMy2DHotWireCuttingDlg::mirrorlUD(CString _srcPath,CString _dstPath)

{

Mat src = imread(_srcPath.GetBuffer(),CV_LOAD_IMAGE_UNCHANGED);   

Mat dst; 

flip(src, dst, 0); 

imwrite(_dstPath.GetBuffer(), dst); 

}

//左右镜像 = 1

void CMy2DHotWireCuttingDlg::Onmirrorlr()

{

// TODO: 在此添加命令处理程序代码

if (loadimgPath == "")

{

if (CorE)

AfxMessageBox("plese click image");

else

AfxMessageBox("请先选择图像");

}

else

{

CString nowTime;

nowTime = m_pData.getNowTime();

//////////////////////////////////////////////////拷贝数据////////////////////////////////////////////////////////////////////////////////////////

CString listShowImg;

listShowImg = loadMoveFilePath.Left(loadMoveFilePath.GetLength()-4);

CopyFile(loadimgPath,g_curDirectoryPath + "res\\backupsFile\\image1\\"+deleteFileName+"\\"+nowTime+".bmp",false);    //¿½±´¶ÁÈ¡Êý¾ÝͼƬ

mirrorlRL(g_curDirectoryPath + "res\\backupsFile\\image\\"+deleteFileName+"\\"+listShowImg+".jpg","res\\backupsFile\\image\\"+deleteFileName+"\\"+nowTime+".jpg"); //¾µÏñ¿½±´ÁбíÏÔʾÊý¾ÝͼƬ

mirrorlRL(printfPath,g_curDirectoryPath + "res\\backupsFile\\image2\\"+deleteFileName+"\\"+nowTime+".bmp");  //¾µÏñ¿½±´´òÓ¡Êý¾ÝͼƬ

//////////////////////////////////////////////////修改信息///////////////////////////////////////////////////////////////////////////////////////

CStdioFile *loadblockData;

loadblockData = new CStdioFile;

vector<CString> blockDataStrs;

CString tempStr;

if (loadblockData->Open(blockPath,CFile::modeRead))

{

while (loadblockData->ReadString(tempStr))

{

blockDataStrs.push_back(tempStr);

}

loadblockData->Close();

}

blockDataStrs[0] = "1";

CString newblockStr;

for (int i = 0; i < blockDataStrs.size(); i++)

{

newblockStr += blockDataStrs[i]+"\n";

}

if (loadblockData->Open(g_curDirectoryPath + "res\\backupsFile\\blockData\\"+deleteFileName+"\\"+nowTime+".xml",CFile::typeText|CFile::modeCreate|CFile::modeReadWrite))

{

loadblockData->WriteString(newblockStr);

loadblockData->Close();

}

delete loadblockData;

}

//更新列表

//Sleep(200);

updateListImg();

}

//上下镜像  = 2

void CMy2DHotWireCuttingDlg::Onmirrorud()

{

// TODO: 在此添加命令处理程序代码

if (loadimgPath == "")

{

if (CorE)

AfxMessageBox("plese click image");

else

AfxMessageBox("请先选择图像");

}

else

{

CString nowTime;

nowTime = m_pData.getNowTime();

//////////////////////////////////////////////////拷贝数据///////////////////////////////////////////////////////////////////////////////////////////

CString listShowImg;

listShowImg = loadMoveFilePath.Left(loadMoveFilePath.GetLength()-4);

CopyFile(loadimgPath,g_curDirectoryPath + "res\\backupsFile\\image1\\"+deleteFileName+"\\"+nowTime+".bmp",false);    //¿½±´¶ÁÈ¡Êý¾ÝͼƬ

mirrorlUD(g_curDirectoryPath + "res\\backupsFile\\image\\"+deleteFileName+"\\"+listShowImg+".jpg","res\\backupsFile\\image\\"+deleteFileName+"\\"+nowTime+".jpg");  //¾µÏñ¿½±´ÁбíÏÔʾÊý¾ÝͼƬ

mirrorlUD(printfPath,g_curDirectoryPath + "res\\backupsFile\\image2\\"+deleteFileName+"\\"+nowTime+".bmp");  //¾µÏñ¿½±´´òÓ¡Êý¾ÝͼƬ

//////////////////////////////////////////////////修改信息///////////////////////////////////////////////////////////////////////////////////////////

CStdioFile *loadblockData;

loadblockData = new CStdioFile;

vector<CString> blockDataStrs;

CString tempStr;

if (loadblockData->Open(blockPath,CFile::modeRead))

{

while (loadblockData->ReadString(tempStr))

{

blockDataStrs.push_back(tempStr);

}

loadblockData->Close();

}

blockDataStrs[0] = "2";

CString newblockStr;

for (int i = 0; i < blockDataStrs.size(); i++)

{

newblockStr += blockDataStrs[i]+"\n";

}

if (loadblockData->Open(g_curDirectoryPath + "res\\backupsFile\\blockData\\"+deleteFileName+"\\"+nowTime+".xml",CFile::typeText|CFile::modeCreate|CFile::modeReadWrite))

{

loadblockData->WriteString(newblockStr);

loadblockData->Close();

}

delete loadblockData;

}

//更新列表

//Sleep(200);

updateListImg();

}

//清除泡沫

void CMy2DHotWireCuttingDlg::Ondeleteblock()

{

// TODO: 在此添加命令处理程序代码

m_mainInterface.clearImg();

vector<CString> deleteFileStr;

deleteFileStr = m_pData.ScanDiskFile(g_curDirectoryPath + "res\\backupsFile\\panel\\");

for (int i = 0; i < deleteFileStr.size(); i++)

{

DeleteFile(g_curDirectoryPath + "res\\backupsFile\\panel\\"+deleteFileStr[i]);

}

if (!b_clearBlock)

{

drawBlockBk();

b_clearBlock = true;

}

// CDC *mDc;

// mDc = GetDlgItem(IDC_STATIC_showFeild)->GetDC();

// showBlockMove = new showImage;

// showBlockMove->loadShowImage("res\\Panel.jpg");

// showBlockBkImg.drawShowImage(mDc->m_hDC,0,8);

// showBlockMove->drawShowImage(mDc->m_hDC,91,99);

// delete showBlockMove;

}

void CMy2DHotWireCuttingDlg::OnClose()

{

// TODO: 在此添加消息处理程序代码和/或调用默认值

CDialogEx::OnClose();

}

void CMy2DHotWireCuttingDlg::OnCancel()

{

// TODO: 在此添加专用代码和/或调用基类

m_mainInterface.clearNoCutImg();

KillTimer(1);

CDialogEx::OnCancel();

}

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 201,312评论 5 473
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 84,578评论 2 377
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 148,337评论 0 333
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,134评论 1 272
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,161评论 5 363
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,303评论 1 280
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,761评论 3 393
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,421评论 0 256
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,609评论 1 295
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,450评论 2 317
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,504评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,194评论 3 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,760评论 3 303
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,836评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,066评论 1 257
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,612评论 2 348
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,178评论 2 341

推荐阅读更多精彩内容