物探论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 590|回复: 0

在MapX中实现图元闪烁原码

[复制链接]
发表于 2013-3-15 18:26:50 | 显示全部楼层 |阅读模式
在MapX中实现图元闪烁原码
MapX图元分三种类型:
1、线(Line),即miFeatureTypeLine
2、区域(Region),即miFeatureTypeRegion
3、点符号(Symbol),即miFeatureTypeSymbol
加入一个时钟控件,并在时钟控件中实现以下代码:
procedure TMapFrm.tmFlashSelectTimer(Sender: TObject);
var
ft: CMapXFindFeature;
lyr: CMapXLayer;
bExist: Boolean;
i: Integer;
str: String;
ds: CMapXDataset;
begin
bExist := False;
for i := 1 to mapCity.Layers.Count do
begin
if mapCity.Layers.Item[i].Name = m_strSelLyr then
begin
bExist := True;
break;
end;
end;
if not bExist then
begin
tmFlashSelect.Enabled := False;
MsgFrm := TMsgFrm.Create(Self);
MsgFrm.m_strMsg := Format('图层[%s]信息不存在!',[m_strSelLyr]);
MsgFrm.ShowModal;
MsgFrm.Free;
Exit;
end;
lyr := mapCity.Layers._Item(m_strSelLyr);
ds := mapCity.Datasets.Add(miDataSetLayer, lyr ,EmptyParam, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam);
lyr.Find.FindDataset := ds;
lyr.Find.FindField := ds.Fields.Item[1];
str := Format('%d',[m_nSelID]);
ft := lyr.Find.Search(str,EmptyParam);
if ft.FindRC mod 10 <> 1 then
begin
tmFlashSelect.Enabled := False;
MsgFrm := TMsgFrm.Create(Self);
MsgFrm.m_strMsg := Format('单位点[%s]信息不存在!',[m_strCorpName]);
MsgFrm.ShowModal;
MsgFrm.Free;
Exit;
end;
case ft.type_ of
miFeatureTypeLine:
begin
if ft.Style.LineColor = miColorWhite then
ft.Style.LineColor := miColorRed
else
ft.Style.LineColor := miColorWhite;
end;
miFeatureTypeRegion:
begin
if ft.Style.RegionColor = miColorGreen then
ft.Style.RegionColor := miColorRed
else
ft.Style.RegionColor := miColorGreen;
end;
miFeatureTypeSymbol:
begin
if not m_bFlashSel then
lyr.Selection.Replace(ft)
else
lyr.Selection.ClearSelection;
m_bFlashSel := not m_bFlashSel;
end;
end;
ft.Update(EmptyParam, EmptyParam);
if not m_bCenter then
begin
m_bCenter := True;
mapCity.CenterX := ft.CenterX;
mapCity.CenterY := ft.CenterY;
mapCity.Refresh;
end;
end;
我这里是把选中的图元实现闪烁,并把图元居中
实现图元闪烁的另一个方法:
假设图元原大小是20,改变后大小是15
if ft.Style.SymbolBitmapSize=20 then
ft.Style.SymbolBitmapSize:=15
else
ft.Style.SymbolBitmapSize:=20;
ft.Update(EmptyParam, EmptyParam);
ft是symbol类型的

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|物探论坛 ( 鄂ICP备12002012号 微信号:iwutan )

GMT+8, 2024-5-12 12:53 , Processed in 0.077506 second(s), 15 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表