?? mapxcontainer.pas
字號:
const Standalone:Boolean; ActionId:Integer):feature; overload;
function AddMultiPoint(Points:CMapXPoints; mstyle:OleVariant;
const Standalone:Boolean; ActionId:Integer):feature; overload;
{增加線對象}
function AddLine(const x1, y1, x2, y2: Double; mstyle:OleVariant;
const Standalone:Boolean; ActionId:Integer):feature; overload;
function AddLine(Parts:TMapPartList; mstyle:OleVariant;
const Standalone:Boolean; ActionId:Integer):feature; overload;
function AddLine(Parts:CMapXParts; mstyle:OleVariant;
const Standalone:Boolean; ActionId:Integer):feature; overload;
{增加圓對象}
function AddCircle(const x, y, r: Double;
mstyle:OleVariant; const Standalone:Boolean; ActionId:Integer):feature;
{增加矩形線框}
function AddRectLine(const x1, y1, x2, y2: Double;
mstyle:OleVariant; const Standalone:Boolean; ActionId:Integer):feature;
{增加圓形區(qū)域}
function AddCircleRegion(const x, y, r: Double;
mstyle:OleVariant; const Standalone:Boolean; ActionId:Integer):feature;
{繪制正多邊形區(qū)域}
function AddSRegion(const x, y, r:Double; const s:Integer;
mstyle:OleVariant; const Standalone:Boolean; ActionId:Integer):feature;
{繪制CircularRegion}
function AddCircularRegion(const _Type:Smallint;
const x, y, r:Double; const s:Integer;
mstyle:OleVariant; const Standalone:Boolean; ActionId:Integer):feature;
{增加橢圓對象}
function AddEllipticalRegion(const x1, y1, x2, y2:Double;
const s:Integer; mstyle:OleVariant; const Standalone:Boolean;
ActionId:Integer):feature;
{增加矩形面對象}
function AddRectangle(const x1, y1, x2, y2: Double; const Caption:string;
mstyle:OleVariant; const Standalone:Boolean; ActionId:Integer):feature;
{增加多邊形對象}
function AddRegion(Parts:TMapPartList; mstyle:OleVariant;
const Standalone:Boolean; ActionId:Integer):feature; overload;
function AddRegion(Parts:CMapXParts; mstyle:OleVariant;
const Standalone:Boolean; ActionId:Integer):feature; overload;
{創(chuàng)建動態(tài)文字對象,動態(tài)文字對象可以編輯}
function AddText(const x, y: Double; const Caption:string;
mstyle:OleVariant; const Standalone:Boolean; ActionId:Integer):feature;
{插入圖塊}
procedure AddBlock(const FileName:string);
{從結(jié)果集加載圖形}
function LoadFeaturesFromDataSet(RomateDS: TCustomADODataSet;
LocalDS:CMapXDataSet; MapFields:TMapFieldList):CMapXLayer;
{保存到結(jié)果集}
procedure SaveFeaturesToDataSet(RomateDS: TCustomADODataSet;
LocalDS:CMapXDataSet; MapFields:TMapFieldList);
{保存圖層到表}
procedure SaveFeaturesToTable(RomateDS:TADOQuery; LocalDS:CMapXDataSet;
const ADBType:TDBType; const TableName:string);
{從表加載圖形}
procedure LoadFeaturesFromTable(RomateDS:TADOQuery;
const TableName:string; MapFields:TMapFieldList);
//----------------------------------------------------------------------//
{區(qū)域轉(zhuǎn)為線框}
function AddLineFromRegion(fts:Feature; mstyle:OleVariant):feature;
procedure AddLinesFromSelectedRegions;
{線框轉(zhuǎn)為區(qū)域}
function AddRegionFromLine(fts:Feature; mstyle:OleVariant):feature;
procedure AddRegionsFromSelectedLines;
//----------------------------------------------------------------------//
{圖形是否相交}
function TestCross(fts1, fts2: Feature):Boolean;
{取得圖形交點坐標(biāo)}
function GetCrossPoint(fts1, fts2: Feature):Feature;
//----------------------------------------------------------------------//
{全選}
procedure SelectAll;
{取消選擇}
procedure UnSelectAll;
{反選}
procedure InvertSelection;
//----------------------------------------------------------------------//
{復(fù)制}
procedure Copy;
{剪切}
procedure Cut;
{粘貼}
procedure Paste;
{刪除圖形}
procedure DeleteFeature(ft:Feature; ActionId:Integer);
{刪除選擇圖形}
procedure DeleteSelectedFeatures;
{刪除所有圖形}
procedure DeleteAllFeatures;
{A+B運算}
function CombineSelectedShapes:Feature;
{切斷區(qū)域或線}
procedure BreakFeatureLineOrRegion(sFt:Feature); overload;
procedure BreakFeatureLineOrRegion(sFts:Features); overload;
{分解運算}
procedure SeparateFeature(ft:Feature);
{緊縮圖層
miPackGraphics = $00000001;
miRebuildGraphics = $00000002;
miPackIndex = $00000004;
miRebuildIndex = $00000008;
miPackData = $00000010;
miPackCompactDB = $00000020;
miPackAll = $00000015;}
procedure Pack(const PackType:Integer);
//----------------------------------------------------------------------//
{顯示屬性對話框}
procedure ShowPropDialog(Ft:Feature);
//----------------------------------------------------------------------//
{是否有結(jié)果集}
function HasDataSet:Boolean;
{是否存在TAB結(jié)果集}
function GetTABDataSet:CMapXDataSet;
{給圖層關(guān)聯(lián)TAB結(jié)果集}
procedure AddTABDataSet(const ADataSetName:string);
{給圖層關(guān)聯(lián)ADO結(jié)果集}
procedure AddADODataSet(const KeyFieldName:string; AQueryObj:TADOQuery);
//----------------------------------------------------------------------//
{地圖管理者}
property MapManager:TMapManager read FMapManager write FMapManager;
{地圖對象}
property MapX:TMapXObject read GetMapX;
{當(dāng)前編輯的圖層}
property Layer:CMapXLayer read FLayer write FLayer;
{標(biāo)注文本樣式}
property LabelStyle:Style read GetLabelStyle;
{標(biāo)注位置}
property LabelPosition:TLabelPosition read GetLabelPosition
write SetLabelPosition;
{分析圖形、創(chuàng)建屬性對話框}
property OnCtrlPropDialog:TMapXFeatureEvent read FOnCtrlPropDialog
write FOnCtrlPropDialog;
{刪除圖形前}
property BeforeDeleteFeature:TBeforeDeleteMapXFeature
read FBeforeDeleteFeature write FBeforeDeleteFeature;
{粘貼每一個圖形觸發(fā)的事件}
property OnFeatureCreate:TMapXFeatureEvent read FOnFeatureCreate
write FOnFeatureCreate;
end;
TLayersManager=class
private
FMapX: TMapXObject;
function GetActiveLayer: CMapXLayer;
procedure SetActiveLayer(const Value: CMapXLayer);
procedure InitComFields(Flds:Fields; MapFields:TMapFieldList);
protected
property MapX:TMapXObject read FMapX write FMapX;
public
procedure GetLayerNames(List:TStrings);
{從文件創(chuàng)建圖層}
function CreateLayerFromFile(const LayerName, FileName:string;
const Index:Integer; const bAddData:Boolean):CMapXLayer;
{從文件創(chuàng)建一組圖層}
procedure CreateLayersFromFiles(List:TStrings; const FromIndex:Integer;
const bAddData:Boolean);
{創(chuàng)建默認(rèn)臨時圖層}
function CreateDefaultTempLayer(const LayerName:string;
const Index:Integer):CMapXLayer;
{創(chuàng)建一般臨時圖層}
function CreateCustomTempLayer(const LayerName:string;
MapFields:TMapFieldList; const Index:Integer;
const bAddData:Boolean):CMapXLayer;
{創(chuàng)建永久圖層}
function CreateCustomTableLayer(const LayerName, FilePath:string;
MapFields:TMapFieldList; const Index:Integer;
const bAddData:Boolean):CMapXLayer;
{從結(jié)果集創(chuàng)建標(biāo)記圖層,該結(jié)果集中存儲著標(biāo)記的X、Y、商業(yè)數(shù)據(jù)}
function CreateSymbolLayerFromDataSet(const LayerName, DataSetName,
XFieldName, YFieldName, KeyFieldName, TabFileName:string;
DS:TCustomADODataSet):CMapXLayer;
function CreateNormalLayerFromDataSetAndLayer(const LayerName, DataSetName,
KeyFieldName:string; DS:TCustomADODataSet):CMapXLayer;
{從結(jié)果集和本地圖層數(shù)據(jù)創(chuàng)建標(biāo)記圖層,該結(jié)果集中存儲著標(biāo)記的商業(yè)數(shù)據(jù),圖層
中存儲著標(biāo)記的X、Y、樣式。注意圖層數(shù)據(jù)中所有圖形都將顯示出來,對于沒有記錄
的標(biāo)記,其商業(yè)數(shù)據(jù)為空白記錄。}
function CreateSymbolLayerFromDataSetAndLayer(const LayerName, DataSetName,
RefColumn, KeyFieldName, TabFileName:string; DS:TCustomADODataSet):CMapXLayer;
{創(chuàng)建內(nèi)存圖層}
function CreateUserDrawLayer(const LayerName:string):CMapXLayer;
{保存圖層}
function CopyLayer(ALyr:Layer; const DataSetIndex:Word;
const FileName:string; const StructOnly:Boolean;
const Index:Integer; const bAddData:Boolean;
const AddFtsType:Integer):CMapXLayer;
{將一個圖層的數(shù)據(jù)加入到另一個圖層,前提條件:屬性表結(jié)構(gòu)相同}
procedure UnionFeature(ToLayer, FromLayer:Layer; const DataSetIndex:Word;
const strWhere:string; const AddFtsType:Integer);
{用名稱取得圖層的索引號}
function IndexByName(const LayerName:string):Integer;
{用名稱取得圖層對象}
function FindByName(const LayerName:string):CMapXLayer;
{用圖層對象索引}
function IndexByLayer(ALyr:Layer):Integer;
{移出所有圖層}
procedure RemoveAll;
{移出指定圖層}
procedure Remove(const Index:Integer);
{用名稱移出圖層}
procedure RemoveByName(const LayerName:string);
{移動圖層}
procedure Move(const FromIndex, ToIndex:Integer);
procedure MoveToTop(const Index:Integer);
procedure MoveToBottom(const Index:Integer);
{合并圖層}
procedure Merge(const LayerIndexes:string);
{壓縮圖層}
procedure Pack(const PackType:Integer);
{活動圖層}
property ActiveLayer:CMapXLayer read GetActiveLayer write SetActiveLayer;
end;
TFeatureClass=class
private
FFeatureListCanChanged: Boolean;
FTableStructCanChanged: Boolean;
FFeatureClassName: string;
FFields: TMapFieldList;
FFeatureList: TBusinessFeatureList;
FParams: TStrings;
FScript: string;
public
constructor Create;
destructor Destroy;override;
{從流加載配置}
procedure LoadFromStream(Stream:TStream);
{保存配置到流}
procedure SaveToStream(Stream:TStream);
{圖形類名稱}
property FeatureClassName:string read FFeatureClassName
write FFeatureClassName;
{描述信息}
property Script:string read FScript write FScript;
{表結(jié)構(gòu)是否可以變化}
property TableStructCanChanged:Boolean read FTableStructCanChanged
write FTableStructCanChanged;
{字段列表,如果圖形類允許異構(gòu)表結(jié)構(gòu),則可以修改,否則不可以修改}
property Fields:TMapFieldList read FFields;
{支持的商業(yè)圖形列表是否可以修改}
property FeatureListCanChanged:Boolean read FFeatureListCanChanged
write FFeatureListCanChanged;
{支持的商業(yè)圖形類型,如果圖層類允許變動商業(yè)圖形列表,則可以修改,否則不可以修改}
property FeatureList:TBusinessFeatureList read FFeatureList;
{圖層參數(shù)}
property Params:TStrings read FParams;
end;
TFeatureClassList=class
private
FList:TList;
function GetItemCount:Integer;
function GetItem(Index:Integer):TFeatureClass;
public
constructor Create;
destructor Destroy;override;
procedure Add(Value:TFeatureClass);overload;
function Add:TFeatureClass;overload;
procedure Insert(const Index:Integer;Value:TFeatureClass);overload;
function Insert(const Index:Integer):TFeatureClass;overload;
procedure Delete(const Index:Integer);
procedure Clear;
procedure LoadFromStream(Stream:TStream);
procedure SaveToStream(Stream:TStream);
property ItemCount:Integer read GetItemCount;
property Items[Index:Integer]:TFeatureClass read GetItem;
end;
{所有地圖控制工具的管理者類,使那些零散的地圖控制類集中到一起,
便于調(diào)用}
TMapCtrlTools=class(TComponent)
private
FMapX: TMapXObject;
Fm_Layers: TLayersManager;
Fm_Map: TMapManager;
Fm_Layer: TLayerManager;
procedure SetMapX(const Value: TMapXObject);
protected
procedure RegisterSymbols;
public
constructor Create(AOwner:TComponent);override;
destructor Destroy;override;
{MapX控件}
property MapX:TMapXObject read FMapX write SetMapX;
{地圖控制類}
property m_Map:TMapManager read Fm_Map;
{圖層控制類}
property m_Layer:TLayerManager read Fm_Layer;
{圖層列表控制類}
property m_Layers:TLayersManager read Fm_Layers;
end;
implementation
uses
BusinessDialogs, StreamIOAPIs, WinFileSystem, MapXAPIs;
{ TMapManager }
constructor TMapManager.Create;
begin
inherited Create;
FUserStyles:=TStyleInfoList.Create;
FSysStyles:=TStyleInfoList.Create;
FSysTools:=TToolList.Create;
// FSysTools.MapManager := Self;
FUserTools:=TToolList.Create;
// FUserTools.MapManager := Self;
FAddFeatureToolUsedEventProces:=TObjectMethodList.Create;
FAnnotationAddedEventProces:=TObjectMethodList.Create;
FAnnotationChangedEventProces:=TObjectMethodList.Create;
FClickEventProces:=TObjectMethodList.Create;
FDataMismatchEventProces:=TObjectMethodList.Create;
FDblClickEventProces:=TObjectMethodList.Create;
FDrawUserLayerEventProces:=TObjectMethodList.Create;
FMouseDownEventProces:=TObjectMethodList.Create;
FMouseMoveEventProces:=TObjectMethodList.Create;
FMouseUpEventProces:=TObjectMethodList.Create;
FMouseWheelEventProces:=TObjectMethodList.Create;
FRequestDataEventProces:=TObjectMethodList.Create;
FResolveDataBindEventProces:=TObjectMethodList.Create;
FResolveDataBindExEventProces:=TObjectMethodList.Create;
FSelectionChangedEventProces:=TObjectMethodList.Create;
FStartDragEventProces:=TObjectMethodList.Create;
FThemeModifyRequestedEventProces:=TObjectMethodList.Create;
FToolUsedEventProces:=TObjectMethodList.Create;
FSelectionDeletedEventProces:=TObjectMethodList.Create;
end;
destructor TMapManager.Destroy;
begin
if MapX<>nil then
begin
MapX.OnKeyDown:=nil;
MapX.OnKeyPress:=nil;
MapX.OnKeyUp:=nil;
MapX.OnMouseDown:=nil;
MapX.OnMouseMove:=nil;
MapX.OnMouseUp:=nil;
MapX.OnDragDrop:=nil;
MapX.OnDragOver:=nil;
MapX.OnEndDrag:=nil;
MapX.OnEnter:=nil;
MapX.OnExit:=nil;
end;
FAddFeatureToolUsedEventProces.Free;
FAnnotationAddedEventProces.Free;
FAnnotationChangedEventProces.Free;
FClickEventProces.Free;
FDataMismatchEventProces.Free;
FDblClickEventProces.Free;
FDrawUserLayerEventProces.Free;
FMouseDownEventProces.Free;
FMouseMoveEventProces.Free;
FMouseUpEventProces.Free;
FMouseWheelEventProces.Free;
FRequestDataEventProces.Free;
FResolveDataBindEventProces.Free;
FResolveDataBindExEventProces.Free;
FSelectionChangedEventProces.Free;
FStartDragEventProces.Free;
FThemeModifyRequestedEventProces.Free;
FToolUsedEventProces.Free;
FSelectionDeletedEventProces.Free;
FSysTools.Free;
FUserTools.Free;
FUserStyles.Free;
FSysStyles.Free;
inherited Destroy;
end;
procedure TMapManager.DoMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
i:Integer;
pProc:TMouseEvent;
begin
for i:=0 to FMouseDownEventProces.Count-1 do
begin
pProc:=TMouseEvent(FMouseDownEventProces.Items[i].Method);
pProc(Sender, Button, Shift, X, Y);
end;
end;
procedure TMapManager.DoMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
i:Integer;
pProc:TMouseMoveEvent;
begin
for i:=0 to FMouseMoveEventProces.Count-1 do
begin
pProc:=TMouseMoveEvent(FMouseMoveEventProces.Items[i].Method);
pProc(Sender, Shift, X, Y);
end;
end;
procedure TMapManager.DoMouseUp(Sender: TObject; Button: TMouseButton;
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -