资源目录
压缩包内文档预览:
编号:6894998
类型:共享资源
大小:654.24KB
格式:RAR
上传时间:2018-01-02
上传人:专业****设计
认证信息
个人认证
葛**(实名认证)
江苏
IP属地:江苏
20
积分
- 关 键 词:
-
定做请加QQ:
1060741974
参考网站
http://www.bysj360.com/
http://www.bylw520.ne
- 资源描述:
-
VB022用VB开发交互式cad系统,定做请加QQ:,1060741974,
,参考网站
,/
,http://www.bylw520.ne
- 内容简介:
-
1.图元的变换(1)直线段的几何变换直线段的平移变换PrivateSubCGElement_Move(basePosAsPosition,desPosAsPosition)DimxxAsDouble,yyAsDouble计算横向移动的距离和纵向移动的距离xx=desPos.x-basePos.xyy=desPos.y-basePos.ySetm_pLineBegin=m_pLineBegin.pntMove(xx,yy)Setm_pLineEnd=m_pLineEnd.pntMove(xx,yy)EndSub(2)直线段的旋转变换直线段的旋转变换PrivateSubCGElement_Rotate(basePosAsPosition,AngleAsDouble)Setm_pLineBegin=m_pLineBegin.pntRotate(basePos,Angle)Setm_pLineEnd=m_pLineEnd.pntRotate(basePos,Angle)EndSub2多义线的几何变换(1)多义线的平移变换PrivateSubCGElement_Move(basePosAsPosition,desPosAsPosition)DimxxAsDouble,yyAsDoubleDimiAsIntegerDimpointAsNewPositionDimMoveedPoints(1To100)AsNewPositionxx=desPos.x-basePos.xyy=desPos.y-basePos.yFori=m_intPLinePointNumTo1Step-1Setpoint=m_pPLPoints(m_ID_PLine,i)Setpoint=point.pntMove(xx,yy)SetMoveedPoints(i)=pointNextiFori=1Tom_intPLinePointNumSetm_pPLPoints(m_ID_PLine,i)=MoveedPoints(i)NextiEndSub(2)多义线的旋转变换PrivateSubCGElement_Rotate(basePosAsPosition,AngleAsDouble)DimiAsIntegerDimpointAsPositionDimRotatedPoints(1To100)AsNewPositionFori=m_intPLinePointNumTo1Step-1Setpoint=m_pPLPoints(m_ID_PLine,i)Setpoint=point.pntRotate(basePos,Angle)SetRotatedPoints(i)=pointNextiFori=1Tom_intPLinePointNumSetm_pPLPoints(m_ID_PLine,i)=RotatedPoints(i)NextiEndSub3圆的几何变换(1)圆的平移变换圆的平移变换PrivateSubCGElement_Move(basePosAsPosition,desPosAsPosition)DimxxAsDouble,yyAsDoublexx=desPos.x-basePos.xyy=desPos.y-basePos.ySetm_pCenter=m_pCenter.pntMove(xx,yy)Setm_pCircleR=m_pCircleR.pntMove(xx,yy)EndSub(3)圆的旋转变换圆的旋转变换PrivateSubCGElement_Rotate(basePosAsPosition,AngleAsDouble)Setm_pCenter=m_pCenter.pntRotate(basePos,Angle)Setm_pCircleR=m_pCircleR.pntRotate(basePos,Angle)EndSub4.圆弧的几何变换(1)圆弧的平移变换圆弧的平移变换PrivateSubCGElement_Move(basePosAsPosition,desPosAsPosition)DimxxAsDouble,yyAsDoublexx=desPos.x-basePos.xyy=desPos.y-basePos.ySetm_pCenter=m_pCenter.pntMove(xx,yy)Setm_pBegin=m_pBegin.pntMove(xx,yy)Setm_pEnd=m_pEnd.pntMove(xx,yy)EndSub(2)圆弧的旋转变换圆弧的旋转变换PrivateSubCGElement_Rotate(basePosAsPosition,AngleAsDouble)Setm_pCenter=m_pCenter.pntRotate(basePos,Angle)Setm_pBegin=m_pBegin.pntRotate(basePos,Angle)Setm_pEnd=m_pEnd.pntRotate(basePos,Angle)EndSub2.3图形变换交互功能的实现2.3.1平移变换CMOVE类Cmove.clsOptionExplicitImplementsCCommandDimintEntSelectedNumAsInteger单击鼠标左键时发生PrivateSubCCommand_LButtonDown(pPosAsPosition)DimiAsIntegerDimpGElementAsCGElementDimpLineAsNewCLineDimpPLineAsNewCPolyLineDimpCircleAsNewCCircleDimpArcAsNewCArc将绘图环境的绘图模式设置为6DrawMain.picDraw.DrawMode=6intmStep记录鼠标左键的单击次数intmStep=intmStep+1SelectCaseintmStepCase1SetptBasePos=pPosSetptDesPos=pPos请输入平移的目标点:Case2SetptDesPos=pPosDimpTempLineAsCLineSetpTempLine=NewCLine清除鼠标移动时留下的橡皮线SetptLineBegin=ptBasePosSetptLineEnd=ptDesPosWithpTempLineSet.pLineBegin=ptLineBeginSet.pLineEnd=ptLineEndEndWithSetpGElement=pTempLinepGElement.Draw(edmNormal)SetpTempLine=Nothing将绘图环境的绘图模式设置为13DrawMain.picDraw.DrawMode=13如果选择集中有图元,将所有图元移动到目标位置并进行绘制IfSelEntityNum()0ThenForEachpLineInSelLinesSetpGElement=pLineWithpGElement.Draw(edmDelete)清除原来位置上的图元Call.Move(ptBasePos,ptDesPos)将图元移到目标位置.Draw(edmSelect)将图元绘制为选择模式EndWithWithpLinelines.Remove(Str(.ID_Line)Calllines.Add(.geLineWidth,.geLineStyle,.geColor,.ID_Line,.pLineBegin,.pLineEnd,Str(.ID_Line)EndWithNextForEachpPLineInSelPLinesSetpGElement=pPLineWithpGElement.Draw(edmDelete)Call.Move(ptBasePos,ptDesPos).Draw(edmSelect)EndWithWithpPLineDimPLPoints(1To100,1To100)AsPositionFori=1TPLinePointNumSetPLPoints(.ID_PLine,i)=.pPLPoints(.ID_PLine,i)Nextipolylines.Remove(Str(.ID_PLine)Callpolylines.Add(.intPLinePointNum,PLPoints,.geLineWidth,.geLineStyle,.geColor,.ID_PLine,Str(.ID_PLine)EndWithNextForEachpCircleInSelCirclesSetpGElement=pCircleWithpGElement.Draw(edmDelete)Call.Move(ptBasePos,ptDesPos).Draw(edmSelect)EndWithWithpCirclecircles.Remove(Str(.ID_Circle)Callcircles.Add(.geLineWidth,.geLineStyle,.geColor,.pCircleR,.pCenter,.ID_Circle,Str(.ID_Circle)EndWithNextForEachpArcInSelArcsSetpGElement=pArcWithpGElement.Draw(edmDelete)Call.Move(ptBasePos,ptDesPos).Draw(edmSelect)EndWithWithpArcarcs.Remove(Str(.ID_Arc)Callarcs.Add(.geLineWidth,.geLineStyle,.geColor,.pCenter,.pBegin,.pEnd,.ID_Arc,Str(.ID_Arc)EndWithNextEndIfDrawMain.picDraw.DrawMode=6intmStep=0EndSelectEndSub移动鼠标时发生PrivateSubCCommand_MouseMove(pPosAsPosition)DimiAsIntegerDimpLineAsNewCLineDimpPLineAsNewCPolyLineDimpCircleAsNewCCircleDimpArcAsNewCArcDimpGElementAsCGElementSelectCaseintmStepCase0请输入镜像的第二点:Case1DimpreposAsNewPositionDimcurposAsNewPositionDimpTempLine1AsCLineDimpTempLine2AsCLineSetpTempLine1=NewCLineSetpTempLine2=NewCLineSetprepos=ptDesPosSetcurpos=pPos清除上一次绘制的橡皮线SetptLineBegin=ptBasePosSetptLineEnd=preposWithpTempLine1Set.pLineBegin=ptLineBeginSet.pLineEnd=ptLineEndEndWithSetpGElement=pTempLine1pGElement.Draw(edmNormal)SetpTempLine1=Nothing绘当前位置的橡皮线SetptLineBegin=ptBasePosSetptLineEnd=curposWithpTempLine2Set.pLineBegin=ptLineBeginSet.pLineEnd=ptLineEndEndWithSetpGElement=pTempLine2pGElement.Draw(edmNormal)SetpTempLine2=Nothing设置橡皮线的终点为当前点SetptDesPos=pPosEndSelectEndSub右击鼠标时发生PrivateSubCCommand_RButtonDown(pPosAsPosition)DimiAsIntegerDimpreposAsPositionSetprepos=NewPositionSetprepos=ptDesPosDimpGElementAsCGElementIfintmStep=1ThenDimpTempLineAsCLineSetpTempLine=NewCLine清除上一个绘制的橡皮线SetptLineBegin=ptBasePosSetptLineEnd=preposWithpTempLineSet.pLineBegin=ptLineBeginSet.pLineEnd=ptLineEndEndWithSetpGElement=pTempLinepGElement.Draw(edmNormal)SetpTempLine=NothingEndIfintmStep=0请输入移动的起始点:EndSubPrivateSubClass_Initialize()EndSub2.3.2旋转变换Rotate.clsOptionExplicitImplementsCCommandDimpGElementAsNewCGElement单击鼠标左键时发生PrivateSubCCommand_LButtonDown(pPosAsPosition)DimiAsIntegerDimAngleAsDoubleDimpLineAsNewCLineDimpPLineAsNewCPolyLineDimpCircleAsNewCCircleDimpArcAsNewCArcDimpGElementAsCGElementDrawMain.picDraw.DrawMode=6intmStep变量记录单击鼠标左键的次数intmStep=intmStep+1SelectCaseintmStepCase1SetptBasePos=pPosSetptDesPos=pPos请输入第二点:Case2SetptDesPos=pPosDimpTempLineAsCLineSetpTempLine=NewCLine清除鼠标移动时留下的橡皮线SetptLineBegin=ptBasePosSetptLineEnd=ptDesPosWithpTempLineSet.pLineBegin=ptLineBeginSet.pLineEnd=ptLineEndEndWithSetpGElement=pTempLinepGElement.Draw(edmNormal)SetpTempLine=Nothing设置绘图模式为13DrawMain.picDraw.DrawMode=13如果选择集不为空,将选择集中的图元旋转到目标位置并进行绘制IfSelEntityNum()0ThenForEachpLineInSelLinesSetpGElement=pLineWithpGElement.Draw(edmDelete)清除原来位置上的图元Angle=GetAngle(ptBasePos,ptDesPos)Call.Rotate(ptBasePos,Angle)将图元旋转到目标位置.Draw(edmSelect)EndWithWithpLinelines.Remove(Str(.ID_Line)Calllines.Add(.geLineWidth,.geLineStyle,.geColor,.ID_Line,.pLineBegin,.pLineEnd,Str(.ID_Line)EndWithNextForEachpPLineInSelPLinesSetpGElement=pPLineWithpGElement.Draw(edmDelete)Angle=GetAngle(ptBasePos,ptDesPos)Call.Rotate(ptBasePos,Angle)将图元移到目标位置.Draw(edmSelect)EndWithWithpPLineDimPLPoints(1To100,1To100)AsPositionFori=1TPLinePointNumSetPLPoints(.ID_PLine,i)=.pPLPoints(.ID_PLine,i)Nextipolylines.Remove(Str(.ID_PLine)Callpolylines.Add(.intPLinePointNum,PLPoints,.geLineWidth,.geLineStyle,.geColor,.ID_PLine,Str(.ID_PLine)EndWithNextForEachpCircleInSelCirclesSetpGElement=pCircleWithpGElement.Draw(edmDelete)Angle=GetAngle(ptBasePos,ptDesPos)Call.Rotate(ptBasePos,Angle)将图元移到目标位置.Draw(edmSelect)EndWithWithpCirclecircles.Remove(Str(.ID_Circle)Callcircles.Add(.geLineWidth,.geLineStyle,.geColor,.pCircleR,.pCenter,.ID_Circle,Str(.ID_Circle)EndWithNextForEachpArcInSelArcsSetpGElement=pArcWithpGElement.Draw(edmDelete)Angle=GetAngle(ptBasePos,ptDesPos)Call.Rotate(ptBasePos,Angle)将图元移到目标位置.Draw(edmSelect)EndWithWithpArcarcs.Remove(Str(.ID_Arc)Callarcs.Add(.geLineWidth,.geLineStyle,.geColor,.pCenter,.pBegin,.pEnd,.ID_Arc,Str(.ID_Arc)EndWithNextEndIfDrawMain.picDraw.DrawMode=6intmStep=0EndSelectEndSubPrivateSubCCommand_MouseMove(pPosAsPosition)DimiAsIntegerDimpGElementAsCGElementSelectCaseintmStepCase0请输入旋转的基点:Case1DimpreposAsNewPositionDimcurposAsNewPositionDimpTempLine1AsCLineDimpTempLine2AsCLineSetpTempLine1=NewCLineSetpTempLine2=NewCLineSetprepos=ptDesPosSetcurpos=pPos清除上一次绘制的橡皮线SetptLineBegin=ptBasePosSetptLineEnd=preposWithpTempLine1Set.pLineBegin=ptLineBeginSet.pLineEnd=ptLineEndEndWithSetpGElement=pTempLine1pGElement.Draw(edmNormal)SetpTempLine1=Nothing在当前位置绘制橡皮线SetptLineBegin=ptBasePosSetptLineEnd=curposWithpTempLine2Set.pLineBegin=ptLineBeginSet.pLineEnd=ptLineEndEndWithSetpGElement=pTempLine2pGElement.Draw(edmNormal)SetpTempLine2=Nothing设置橡皮线的终点为当前点SetptDesPos=pPosEndSelectEndSub右击鼠标时发生PrivateSubCCommand_RButtonDown(pPosAsPosition)DimiAsIntegerDimpGElementAsCGElementDimpreposAsPositionSetprepos=NewPositionSetprepos=ptDesPosIfintmStep=1ThenDimpTempLineAsCLineSetpTempLine=NewCLine清除上一个绘制的橡皮线SetptLineBegin=ptBasePosSetptLineEnd=preposWithpTempLineSet.pLineBegin=ptLineBeginSet.pLineEnd=ptLineEndEndWithSetpGElement=pTempLinepGElement.Draw(edmNormal)SetpTemp
- 温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

人人文库网所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。