📄 designerview.cpp
字号:
PasteInfo.RectsInfo[i].location.y *(int)(m_Step_Line*m_jwm)+1+OFFSET-Scroll.y,
(PasteInfo.RectsInfo[i].location.x+1)*m_Step_Line+OFFSET-Scroll.x,
(PasteInfo.RectsInfo[i].location.y +1)*(int)(m_Step_Line*m_jwm)+OFFSET-Scroll.y),
&cbred);
else if(PasteInfo.RectsInfo[i].pc == m_GREEN)
pDC->FillRect(CRect(PasteInfo.RectsInfo[i].location.x*m_Step_Line+1+OFFSET-Scroll.x,
PasteInfo.RectsInfo[i].location.y *(int)(m_Step_Line*m_jwm)+1+OFFSET-Scroll.y,
(PasteInfo.RectsInfo[i].location.x+1)*m_Step_Line+OFFSET-Scroll.x,
(PasteInfo.RectsInfo[i].location.y +1)*(int)(m_Step_Line*m_jwm)+OFFSET-Scroll.y),
&cbgreen);
else if(PasteInfo.RectsInfo[i].pc == m_BLUE)
pDC->FillRect(CRect(PasteInfo.RectsInfo[i].location.x*m_Step_Line+1+OFFSET-Scroll.x,
PasteInfo.RectsInfo[i].location.y *(int)(m_Step_Line*m_jwm)+1+OFFSET-Scroll.y,
(PasteInfo.RectsInfo[i].location.x+1)*m_Step_Line+OFFSET-Scroll.x,
(PasteInfo.RectsInfo[i].location.y +1)*(int)(m_Step_Line*m_jwm)+OFFSET-Scroll.y),
&cbblue);
else if(PasteInfo.RectsInfo[i].pc == m_YELLOW)
pDC->FillRect(CRect(PasteInfo.RectsInfo[i].location.x*m_Step_Line+1+OFFSET-Scroll.x,
PasteInfo.RectsInfo[i].location.y *(int)(m_Step_Line*m_jwm)+1+OFFSET-Scroll.y,
(PasteInfo.RectsInfo[i].location.x+1)*m_Step_Line+OFFSET-Scroll.x,
(PasteInfo.RectsInfo[i].location.y +1)*(int)(m_Step_Line*m_jwm)+OFFSET-Scroll.y),
&cbyellow);
else if(PasteInfo.RectsInfo[i].pc == m_WHITE)
pDC->FillRect(CRect(PasteInfo.RectsInfo[i].location.x*m_Step_Line+1+OFFSET-Scroll.x,
PasteInfo.RectsInfo[i].location.y *(int)(m_Step_Line*m_jwm)+1+OFFSET-Scroll.y,
(PasteInfo.RectsInfo[i].location.x+1)*m_Step_Line+OFFSET-Scroll.x,
(PasteInfo.RectsInfo[i].location.y +1)*(int)(m_Step_Line*m_jwm)+OFFSET-Scroll.y),
&cbwhite);
else if(PasteInfo.RectsInfo[i].pc == m_OTHER)
pDC->FillRect(CRect(PasteInfo.RectsInfo[i].location.x*m_Step_Line+1+OFFSET-Scroll.x,
PasteInfo.RectsInfo[i].location.y *(int)(m_Step_Line*m_jwm)+1+OFFSET-Scroll.y,
(PasteInfo.RectsInfo[i].location.x+1)*m_Step_Line+OFFSET-Scroll.x,
(PasteInfo.RectsInfo[i].location.y +1)*(int)(m_Step_Line*m_jwm)+OFFSET-Scroll.y),
&cbedge);
}
cbedge.DeleteObject();
cbred.DeleteObject();
cbgreen.DeleteObject();
cbblue.DeleteObject();
cbyellow.DeleteObject();
cbwhite.DeleteObject();
}
void CDesignerView::FillCurrGrid(CPoint currpoint)
{
// FILL THE CURRENT POINT IS M_YELLOW;
PICTURECOLOR gbcol;
if(m_gbcolor == RED)
gbcol = m_RED;
else if(m_gbcolor == GREEN)
gbcol = m_GREEN;
else if(m_gbcolor == BLUE)
gbcol = m_BLUE;
else if(m_gbcolor == YELLOW)
gbcol = m_YELLOW;
else if(m_gbcolor == WHITE)
gbcol = m_WHITE;
m_picture_color[currpoint.y][currpoint.x] = gbcol;
}
bool CDesignerView::RecursiveJudgeIsContinus( CPoint srcPoint,CPoint StartPoint,int *len)
{
if(this->m_picture_edge[srcPoint.x][srcPoint.y] == false)
return false;
else
{
if(srcPoint.x == StartPoint.x && srcPoint.y == StartPoint.y && *len >10)
return true;
else
{
if(this->m_JudgeLab[srcPoint.y][srcPoint.x] == true)
return false;
else
{
this->m_JudgeLab[srcPoint.y][srcPoint.x] = true;
*len++;
CPoint temp;
temp.x = srcPoint.x;
temp.y = srcPoint.y -1;
if(RecursiveJudgeIsContinus(temp,StartPoint,len))
return true;
temp.x = srcPoint.x +1;
temp.y = srcPoint.y -1;
if(RecursiveJudgeIsContinus(temp,StartPoint,len))
return true;
temp.x = srcPoint.x +1;
temp.y = srcPoint.y ;
if(RecursiveJudgeIsContinus(temp,StartPoint,len))
return true;
temp.x = srcPoint.x +1;
temp.y = srcPoint.y +1;
if(RecursiveJudgeIsContinus(temp,StartPoint,len))
return true;
temp.x = srcPoint.x ;
temp.y = srcPoint.y +1;
if(RecursiveJudgeIsContinus(temp,StartPoint,len))
return true;
temp.x = srcPoint.x -1;
temp.y = srcPoint.y +1;
if(RecursiveJudgeIsContinus(temp,StartPoint,len))
return true;
temp.x = srcPoint.x -1;
temp.y = srcPoint.y ;
if(RecursiveJudgeIsContinus(temp,StartPoint,len))
return true;
temp.x = srcPoint.x -1;
temp.y = srcPoint.y -1;
if(RecursiveJudgeIsContinus(temp,StartPoint,len))
return true;
}
}
}
return false;
}
void CDesignerView::OnUpdateEditCopy(CCmdUI* pCmdUI)
{
if(IsCopyUsable)
pCmdUI->Enable(TRUE);
else
pCmdUI->Enable(FALSE);
}
void CDesignerView::OnUpdateEditCut(CCmdUI* pCmdUI)
{
if(IsCutUsable)
pCmdUI->Enable(TRUE);
else
pCmdUI->Enable(FALSE);
}
void CDesignerView::OnUpdateEditPaste(CCmdUI* pCmdUI)
{
if(IsPasteUsable)
pCmdUI->Enable(TRUE);
else
pCmdUI->Enable(FALSE);
}
void CDesignerView::OnUpdateEditReduceColor(CCmdUI* pCmdUI)
{
}
void CDesignerView::OnUpdateMenuGyQuzadian(CCmdUI* pCmdUI)
{
if(IsOtherPictureMenuUsable)
pCmdUI->Enable(TRUE);
else
pCmdUI->Enable(FALSE);
}
void CDesignerView::OnUpdateMenuPicReducecolor(CCmdUI* pCmdUI)
{
if(IsReduceColorUsable)
pCmdUI->Enable(TRUE);
else
pCmdUI->Enable(FALSE);
}
void CDesignerView::OnCircle()
{
CDC *dc = GetDC();
CPoint Scroll = this->GetScrollPosition();
if(this->m_Circle_Scr.IsValide == true)
this->AntCircle(dc,this->m_Circle_Scr,Scroll,false);
if(this->m_RectsInfo.IsValide)
this->AntRectang(dc,Scroll);
ReleaseDC(dc);
this->m_DrawMode = CIRCLE;
}
void CDesignerView::OnJiangliwangge()
{
m_jingmi = 6;
m_weimi = 5 ;
m_jwm = (float)1.2;
////////////////// for test end;
if(m_jwm ==0){
AfxMessageBox("请先输入经纬密度");
return;
}
UpdateData();
m_jwm = this->m_jwm;
m_Base_Create = true;
m_jingmi = this->m_jingmi;
m_weimi = this->m_weimi;
if(hDIB)
{
DIB tmpdib;
LPBITMAPINFOHEADER lpbi;
lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDIB);
m_Step_Line = STEP;
int off_x = STEP - (lpbi->biWidth % STEP);
int off_y = (int)(STEP*m_jwm ) - (lpbi->biHeight % (int)(STEP*m_jwm));
float x_co = (float)off_x/lpbi->biWidth+1.0;
float y_co = (float)off_y/lpbi->biHeight+1.0;
GlobalUnlock(hDIB);
HANDLE htemp;
htemp= tmpdib.ScaleDIB(hDIB,x_co,y_co);
GlobalFree(hDIB);
hDIB = cDib.CopyHandle(htemp);
GlobalFree(htemp);
lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDIB);
m_LineNum.x = lpbi->biWidth/STEP;
m_LineNum.y = lpbi->biHeight/(int)(STEP*m_jwm);
GlobalUnlock(hDIB);
for(int i =0;i<LINENUM;i++)
for(int j=0;j<LINENUM;j++)
m_picture_color[i][j] = m_OTHER;
IsReduceColorUsable = true;
}
if(!hDIB || m_ReduceColor == true)
{
for(int i = 0;i<(int)(LINENUM/2.5);i++)
for(int j=0;j<(int)(LINENUM/2.5);j++)
m_picture_color[i][j] = m_WHITE;
m_LineNum.x = LINENUM/2.5;
m_LineNum.y = LINENUM/2.5;
m_Step_Line = STEP;
m_ReduceColor = false;
//pShowPhotoView->IsEraseEdgeUsable = true;
for( i=0;i<LINENUM;i++)
for(int j=0;j<LINENUM;j++)
m_picture_edge[i][j] = false;
if(hDIB)
{
GlobalFree(hDIB);
hDIB = NULL;
}
}
Invalidate();
}
void CDesignerView::OnPen()
{
this->m_DrawMode = PEN;
}
void CDesignerView::OnXiqu()
{
this->m_DrawMode = XIQU;
}
void CDesignerView::OnZuzhi()
{
m_jingmi = 6;
m_weimi = 5;
TextureJW jw;
jw.m_coeff = this->m_jingmi/this->m_weimi;
jw.m_jm = this->m_jingmi;
jw.m_wm = this->m_weimi;
if(jw.DoModal() == IDOK)
return;
}
void CDesignerView::OnOpenZuzhi()
{
CFileDialog dlg1(TRUE,"zuz","*.zuz",NULL,"*.zuz",NULL);
FILE *fp;
TEXTRUE *ptextu = new TEXTRUE();
if(dlg1.DoModal() == IDOK)
{
fp = fopen(dlg1.GetPathName(),"r") ;
fscanf(fp,"%d",&(ptextu->m_jing_num) );
fscanf(fp,"%d",&(ptextu->m_wei_num) );
fscanf(fp,"%f",&(ptextu->m_coeff));
fscanf(fp,"%f",&(ptextu->m_jm));
fscanf(fp,"%f",&(ptextu->m_wm));
for(int i = 0;i<ptextu->m_wei_num;i++)
for(int j =0;j<ptextu->m_jing_num;j++)
fscanf(fp,"%d",&(ptextu->m_jwlabel[j][i]));
fclose(fp);
ptextu->m_type = 1;
ptextu->m_texture_color = RGB(255,0,0);
ptextu->m_JN = ptextu->m_jing_num;
ptextu->m_WN = ptextu->m_wei_num;
ptextu->Create();
ptextu->ShowWindow(SW_SHOW);
}
}
void CDesignerView::OnYouqitong()
{
this->m_DrawMode = YOUQITONG;
}
void CDesignerView::OnPenwuqi()
{
PENWUQI pwq;
if(pwq.DoModal() == IDOK)
{
UpdateData(TRUE);
this->m_PenWuQi_Num = pwq.m_Num;
this->m_PenWuQi_Radius = pwq.m_Radius;
if(pwq.m_ColorNum ==0)
this->m_Pen_Color = RED;
else if(pwq.m_ColorNum ==1)
this->m_Pen_Color = GREEN;
else if(pwq.m_ColorNum ==2)
this->m_Pen_Color = BLUE;
else if(pwq.m_ColorNum ==3)
this->m_Pen_Color = YELLOW;
else if(pwq.m_ColorNum ==4)
this->m_Pen_Color = WHITE;
this->m_DrawMode = PENGWUQI;
}
}
void CDesignerView::OnRect()
{
this->m_DrawMode = RECTDRAW;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -