阅读:1747回复:4
MapX控件,超难问题~~~~
<P>MapX控件,在拖动地图时会有大量的空白,怎么解决?</P>
<P>呵呵其实就是那个看都没人看的问题,我这样写只是想吸引一下眼球。</P> <P>因为老板就看这一点,他就不能忍受,这个问题不解决话,决定不用Mapx做Gis 了。</P> <P>而叫我重写GIS,从底层开始写起。</P> |
|
1楼#
发布于:2005-08-13 10:43
<P>用Delphi实现MapX中类似AutoCAD的平滑移动的Pen工具</P>
<P>//类文件 <BR>unit TFlowPenClass; </P> <P>interface <BR>uses Controls,Classes,MapXLib_TLB; <BR>type <BR> TFlowPen=Class(TObject) <BR> protected <BR> m_IriMouseMoveEvent:TMouseMoveEvent; <BR> m_IriMouseUpEvent:TMouseEvent; <BR> m_IriMouseDownEvent:TMouseEvent; <BR> m_pMap:Tmap; <BR> m_bMosueDown:Boolean; <BR> m_sPenInX:Single; <BR> m_sPenInY:Single; <BR> protected <BR> procedure MapMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); <BR> procedure MapMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); <BR> procedure MapMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); <BR> public <BR> Function CreateFlowPenTool(pMap:TMap):Integer; <BR> Function InstallFlowPenTool():Boolean; <BR> Function UnInstallFlowPenTool():Boolean; <BR> Function GetToolNum():Integer; <BR>end; <BR>const <BR> MAP_TOOL_FLOWPEN=1; <BR>implementation </P> <P> procedure TFlowPen.MapMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); <BR> begin <BR> If (m_pMap.CurrentTool=MAP_TOOL_FLOWPEN) And (Not m_bMosueDown) Then <BR> begin <BR> m_bMosueDown:=True; <BR> m_sPenInX:=X; <BR> m_sPenInY:=Y; <BR> end; <BR> if @m_IriMouseDownEvent<>nil then <BR> m_IriMouseDownEvent(Sender,Button,Shift,X,Y); <BR> end; <BR> procedure TFlowPen.MapMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); <BR> begin <BR> If (m_pMap.CurrentTool=MAP_TOOL_FLOWPEN) And m_bMosueDown Then <BR> m_bMosueDown:=False; <BR> if @m_IriMouseUpEvent<>nil then <BR> m_IriMouseUpEvent(Sender,Button,Shift,X,Y); <BR> end; <BR>procedure TFlowPen.MapMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); <BR>var <BR> dX1,dX2,dY1,dY2ouble; <BR> sX,sY:Single; <BR>begin <BR> If (m_pMap.CurrentTool=MAP_TOOL_FLOWPEN) And m_bMosueDown Then <BR> begin <BR> sX:=X;sY:=y; <BR> m_pMap.ConvertCoord(sX,sY,dX1,dY1,miScreenToMap); <BR> m_pMap.ConvertCoord(m_sPenInX,m_sPenInY,dX2,dY2,miScreenToMap); <BR> m_pMap.CenterX:=m_pMap.CenterX-(dX1-dX2); <BR> m_pMap.CenterY:=m_pMap.CenterY-(dY1-dY2); <BR> m_sPenInX:=X; <BR> m_sPenInY:=Y; <BR> End; <BR> if @m_IriMouseMoveEvent<>nil then <BR> m_IriMouseMoveEvent(Sender,Shift,X,Y); <BR>end; <BR>Function TFlowPen.CreateFlowPenTool(pMap:Tmap):Integer; <BR>begin <BR> m_pMap:=pMap; <BR> if m_pMap<>nil then <BR> begin <BR> m_pMap.CreateCustomTool(MAP_TOOL_FLOWPEN,miToolTypePoint,miPanCursor,miPanCursor,miPanCursor); <BR> InstallFlowPenTool; <BR> result:=MAP_TOOL_FLOWPEN; <BR> end <BR> else <BR> result:=-1; <BR>end; <BR>Function TFlowPen.InstallFlowPenTool():boolean; <BR>begin <BR> if m_pMap<>nil then <BR> begin <BR> m_IriMouseMoveEvent:=m_pMap.OnMouseMove; <BR> m_IriMouseUpEvent:=m_pMap.OnMouseUp; <BR> m_IriMouseDownEvent:=m_pMap.OnMouseDown; <BR> m_pMap.OnMouseMove:=MapMouseMove; <BR> m_pMap.OnMouseUp:=MapMouseUp; <BR> m_pMap.OnMouseDown:=MapMouseDown; <BR> m_bMosueDown:=False; <BR> result:=True; <BR> end <BR> else <BR> result:=False; <BR>end; <BR>Function TFlowPen.UnInstallFlowPenTool():Boolean; <BR>begin <BR> if m_pMap<>nil then <BR> begin <BR> m_pMap.OnMouseMove:=m_IriMouseMoveEvent; <BR> m_pMap.OnMouseUp:=m_IriMouseUpEvent; <BR> m_pMap.OnMouseDown:=m_IriMouseDownEvent; <BR> m_IriMouseMoveEvent:=nil; <BR> m_IriMouseUpEvent:=nil; <BR> m_IriMouseDownEvent:=nil; <BR> m_pMap:=nil; <BR> result:=True; <BR> end <BR> else <BR> result:=False; <BR>end; <BR>Function TFlowPen.GetToolNum():Integer; <BR>begin <BR> result:=MAP_TOOL_FLOWPEN; <BR>end; <BR>end. </P> <P>//使用时初试化 <BR> m_FlowPenTool:=TFlowPen.Create; <BR> m_FlowPenTool.CreateFlowPenTool(Map1); <BR>//开始使用FlowPen <BR>Map1.CurrentTool:=m_FlowPenTool.GetToolNum(); </P> <P>//MapX.RedrawInterval设置为30或更大效果会比较好</P> |
|
2楼#
发布于:2005-08-13 17:56
<P>现在做基层开发是很累的,除非你做大了才可以。要不你还不如用二次开发快。商业吧,讲究效益,当老板的当然想这么想。</P>
<P>上面的问题我觉的是因为自动刷新为False了。</P> |
|
|
3楼#
发布于:2005-08-14 16:24
<P>你老板不是搞技术的当然不懂,这种拖动方式节省系统资源,提高刷新速度</P>
<P>那种连续刷新方式在地图信息负载量较大时对人简直是一种折磨</P> <P>在底层上可以使用矩形编码方式提高效率,但是有必要吗 </P> |
|
|
4楼#
发布于:2005-08-15 09:19
<P>有时间,您可以到微图公司走一趟,那里也有一个论坛,或许你就明白当老板的也是很不容易的.因为你不是老板,你体会不到的.</P>
<P>微图公司 <a href="http://www.micromap.com.cn" target="_blank" >http://www.micromap.com.cn</A></P> <P>微图GIS论坛 http://www.micromap.com.cn/bbs</P> |
|
|