当前位置: 代码迷 >> VC >> 怎么扩大,缩小图形
  详细解决方案

怎么扩大,缩小图形

热度:4207   发布时间:2013-02-25 00:00:00.0
如何扩大,缩小图形
为什么我这个图形没有发生任何改变,我不是用scaletrnsfrom扩大20,20的吗?,源代码如下:

#pragma once
#include"HGTRecord.h"
#include"PointD.h"
#using <System.dll>
#using <System.Drawing.dll>


public ref class DrawSelect{
public:
int direct;
PointD Center, aPos_S, aPos_E;
public:
DrawSelect(System::Drawing::Graphics ^g,List<HGTRecord> ^hgtRecord, System::Collections::ArrayList ^ges,DrawH::Virable ^aVirable);
/*DrawSelect(System::Drawing::Graphics ^g,int a,int b,int c,int d,System::Collections::ArrayList ^ges,DrawH::Virable ^aVirable);*/
};
//DrawSelect::DrawSelect(System::Drawing::Graphics ^g,int a,int b,int c,int d,System::Collections::ArrayList ^ges,DrawH::Virable ^aVirable){
// aPos_S.X=a;
// aPos_S.Y=b;
// aPos_E.X=c;
// aPos_E.Y=d;
// DrawH::Line ^tmpLine=gcnew DrawH::Line(aPos_S,aPos_E);
// tmpLine->Draw(g,DrawH::DrawMode::TraceLine,aVirable);
// ges->Add(tmpLine);
//}
DrawSelect::DrawSelect(System::Drawing::Graphics ^g,List<HGTRecord> ^hgtRecord, System::Collections::ArrayList ^ges,DrawH::Virable ^aVirable){
DrawH::Arc ^tmpArc;
array<double,1>^ ar=gcnew array<double,1>(9);
int Count=hgtRecord->Count;
for (int i = 0; i < Count; i++)
  { 
direct=(int)hgtRecord[i].type;
aPos_S.X = (double)hgtRecord[i].startP.X; //起点X坐标
aPos_S.Y = (double)hgtRecord[i].startP.Y;//起点Y坐标
aPos_E.X = (double)hgtRecord[i].endP.X;//终点X坐标
aPos_E.Y = (double)hgtRecord[i].endP.Y;//终点Y坐标
Center.X = (double)hgtRecord[i].centerP.X;
Center.Y = (double)hgtRecord[i].centerP.Y;

//pd用于判断是第一次绘制图形还是扩大或者缩小图形,为0表示第一次绘制图形,为1代表扩大或者缩小图形
if(hgtRecord[i].pd==1){
if (direct==2)//当是顺圆弧
{  
tmpArc=gcnew DrawH::Arc(Center,aPos_E,aPos_S);
tmpArc->Draw(g,DrawH::DrawMode::Trace,aVirable);
ges->Add(tmpArc);
}
else if (direct==3)//当是逆圆弧
{  

tmpArc=gcnew DrawH::Arc(Center,aPos_S,aPos_E);
tmpArc->Draw(g,DrawH::DrawMode::Trace,aVirable);  
ges->Add(tmpArc);
}
else if (direct==1)//当是直线
{
g->ScaleTransform(20,20);
DrawH::Line ^tmpLine=gcnew DrawH::Line(aPos_S,aPos_E);
g->ScaleTransform(50,50);
g->Save();
tmpLine->Draw(g,DrawH::DrawMode::TraceLine,aVirable);
ges->Add(tmpLine);
}
else if (direct==423||direct==424){ //当是引入引出线
DrawH::Line ^tmpArc=gcnew DrawH::Line(aPos_S,aPos_E);
tmpArc->Draw(g,DrawH::DrawMode::LeadLine,aVirable);
ges->Add(tmpArc);
}
tmpArc=nullptr;
}



//第一次绘制图形
else{
if (direct==2)//当是顺圆弧
{  
tmpArc=gcnew DrawH::Arc(Center,aPos_E,aPos_S);
tmpArc->Draw(g,DrawH::DrawMode::Trace,aVirable);
ges->Add(tmpArc);
}
else if (direct==3)//当是逆圆弧
{  

tmpArc=gcnew DrawH::Arc(Center,aPos_S,aPos_E);
tmpArc->Draw(g,DrawH::DrawMode::Trace,aVirable);  
  ges->Add(tmpArc);
}
else if (direct==1)//当是直线
{
DrawH::Line ^tmpLine=gcnew DrawH::Line(aPos_S,aPos_E);
tmpLine->Draw(g,DrawH::DrawMode::TraceLine,aVirable);
ges->Add(tmpLine);
}
else if (direct==423||direct==424){ //当是引入引出线
  DrawH::Line ^tmpArc=gcnew DrawH::Line(aPos_S,aPos_E);
tmpArc->Draw(g,DrawH::DrawMode::LeadLine,aVirable);
ges->Add(tmpArc);
}
tmpArc=nullptr;
}

}


------解决方案--------------------------------------------------------
  相关解决方案