⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frm_mainbase.pas

📁 用Delhpi和mapx开发的警务管理系统
💻 PAS
📖 第 1 页 / 共 3 页
字号:
              SetLength(msArrLayerName,length(msArrLayerName) + 1);
              msArrLayerName[high(msArrLayerName)]:=Map_main.Layers[iLoop].Name;
              Map_main.Layers[iLoop].Selection.SelectByPoint(X1,Y1,miSelectionNew,miSearchResultDefault);
              SetLength(mArrFeatures,length(mArrFeatures) + 1);
              mArrFeatures[high(mArrFeatures)]:=Map_main.Layers[iLoop].Selection.Clone;
            end;
          end;
          for kLoop:= 0 to high(mArrFeatures) do
          begin
            if mArrFeatures[kLoop].Count <> 0 then
            begin
              msLayerName:=msArrLayerName[kLoop];
              break;
            end;
          end;
          MapControl.SetKeyBySelect(msLayerName);
        end;
        miRectSelectTool:  //矩形选
        begin
          for iLoop:= 1 to Map_main.Layers.Count do
          begin
            if Map_main.Layers[iLoop].Selectable=true then
            begin
              SetLength(msArrLayerName,length(msArrLayerName) + 1);
              msArrLayerName[high(msArrLayerName)]:=Map_main.Layers[iLoop].Name;
              Map_main.Layers.Item[sSpaceName].Selection.SelectByRectangle(X1,Y1,X2,Y2,miSelectionNew);
              SetLength(mArrFeatures,length(mArrFeatures) + 1);
              mArrFeatures[high(mArrFeatures)]:=Map_main.Layers[iLoop].Selection.Clone;
            end;
          end;
          for kLoop:= 0 to high(mArrFeatures) do
          begin
            if mArrFeatures[kLoop].Count <> 0 then
            begin
              msLayerName:=msArrLayerName[kLoop];
              break;
            end;
          end;
          MapControl.SetKeyBySelect(msLayerName);
        end;
        miRadiusSelectTool: //圆形选择
        begin
          for iLoop:= 1 to Map_main.Layers.Count do
          begin
            if Map_main.Layers[iLoop].Selectable=true then
            begin
              SetLength(msArrLayerName,length(msArrLayerName) + 1);
              msArrLayerName[high(msArrLayerName)]:=Map_main.Layers[iLoop].Name;
              Map_main.Layers.Item[sSpaceName].Selection.SelectByRadius(X1,Y1,Distance,miSelectionNew);
              SetLength(mArrFeatures,length(mArrFeatures) + 1);
              mArrFeatures[high(mArrFeatures)]:=Map_main.Layers[iLoop].Selection.Clone;
            end;
          end;
          for kLoop:= 0 to high(mArrFeatures) do
          begin
            if mArrFeatures[kLoop].Count <> 0 then
            begin
              msLayerName:=msArrLayerName[kLoop];
              break;
            end;
          end;
          MapControl.SetKeyBySelect(msLayerName);
        end;
      end;
      miMine:=0;
      for iLoop:=0 to tv_Layer.Items.Count -1 do
      begin
        for jLoop:= 0 to tv_Layer.Items[iLoop].Count -1 do
        begin
          tempMapInfo:=tv_Layer.Items[iLoop].Item[jLoop].Data;
          if tempMapInfo.SpaceTableName=msLayerName then
          begin
            tv_Layer.Items[iLoop].Item[jLoop].StateIndex:=15;
            Map_main.Layers.Item[tempMapInfo.SpaceTableName].Selectable:=true;
          end
          else
          begin
            tv_Layer.Items[iLoop].Item[jLoop].StateIndex:=1;
            Map_main.Layers.Item[tempMapInfo.SpaceTableName].Selectable:=false;
          end;
        end;
        Map_main.CurrentTool:=PreviousTool;
      end;
    end;
  except on E: Exception do
  begin
    ShowMessage(E.Message);
  end;
  end;}
end;


procedure TForm_MainBase.Map_mainMapViewChanged(Sender: TObject);
var
   tempFeature:CMapXFeature;
   tempStyle:CMapXStyle;
begin

   if m_Guid_Layer.AllFeatures.Count=0 then
      begin
        tempStyle:=CoStyle.Create;
        tempStyle.RegionPattern:=miPatternNoFill;
        tempStyle.RegionBorderColor:=16711680;
        tempStyle.RegionBorderWidth:=2;
        tempFeature := Map_GuidMap.FeatureFactory.CreateRegion(Map_Main.Bounds, tempstyle);
        m_Guid_Feature := m_Guid_layer.AddFeature(tempFeature,EmptyParam);
      end
   Else
    With m_Guid_Feature.Parts.Item[1] do
    begin
    RemoveAll;
    AddXY(Map_Main.Bounds.XMin,Map_Main.Bounds.YMin,EmptyParam);
    AddXY(Map_Main.Bounds.XMax,Map_Main.Bounds.YMin,EmptyParam);
    AddXY(Map_Main.Bounds.XMax,Map_Main.Bounds.YMax,EmptyParam);
    AddXY(Map_Main.Bounds.XMin,Map_Main.Bounds.YMax,EmptyParam);
    End;
    m_Guid_Feature.Update(EmptyParam, EmptyParam);
end;

procedure TForm_MainBase.Map_GuidMapToolUsed(ASender: TObject;
  ToolNum: Smallint; X1, Y1, X2, Y2, Distance: Double; Shift,
  Ctrl: WordBool; var EnableDefault: WordBool);
var
   kwh,w,h:double;
begin
  case toolnum of
    CreateRectSel:
    begin
      if ((Shift) or (Ctrl) or (Distance<0.2)) then
        with Map_Main.Bounds do
          w:=Map_Main.Distance(xmin,(ymin+ymax)/2,xmax,(ymin+ymax)/2)
      else
      begin
        with Map_Main.Bounds do
          kwh:=(xmax-xmin)/(ymax-ymin);
          w:=abs(x2-x1);
          h:=abs(y2-y1);
          if w<(h*kwh) then
            w:=kwh*Map_GuidMap.Distance(x1,y1,x1,y2)
          else
            w:=Map_GuidMap.Distance(x1,(y1+y2)/2,x2,(y1+y2)/2);
      end;
      Map_Main.ZoomTo(w,(x1+x2)/2,(y1+y2)/2);
    end;
  end;
end;


procedure TForm_MainBase.iDataMining(iDataBaseIndex:array of integer;iToolNum:integer;sMineForm:TForm;iMine:integer);
var
  iLoop:integer;
  iIndex:integer;
  sTemp:string;
begin
  miMine:=iMine;
  mMineForm:=sMineForm;
  for iLoop:=1 to Map_main.Layers.Count do
  begin
    Map_main.Layers.Item[iLoop].Selectable:=false;
  end;

  for iLoop:=0 to HIGH(iDataBaseIndex) do
  begin
    miDataBaseIndex:=iDataBaseIndex[iLoop];
    MapControl.LoadOneDataBaseLayer(iDataBaseIndex[iLoop],1);
  end;
  PreviousTool:=Map_main.CurrentTool;
  Map_main.CurrentTool:=iToolNum;
end;
procedure TForm_MainBase.SpeedButton1Click(Sender: TObject);
var
  tempArr:array of integer;
begin
  SetLength(tempArr,1);
  tempArr[0]:=1;
  iDataMining(tempArr,miSelectTool,self,1);
end;

procedure TForm_MainBase.Map_mainSelectionChanged(Sender: TObject);
var
  sSpaceName: string;
  pNode: pMapInfo;
  Point : CMapXPoint;
  I: Integer;
  arrCaption :array[0..3] of String;
  sArrLayerName:array of string;
  iLoop,jLoop,kLoop:integer;
  tempMapInfo:pMapInfo;
begin
  try
    if (blnToolUsed=true) and ((Map_main.CurrentTool=miSelectTool) or (Map_main.CurrentTool=miRadiusSelectTool) or (Map_main.CurrentTool=miRectSelectTool) or (Map_main.CurrentTool=miPolygonSelectTool)) then
    begin
      sSpaceName:=MapControl.sGetTvSelectSpace;
      if (sSpaceName<>'') and Map_main.Layers.Item[sSpaceName].Selectable then
      begin
            //Map_main.Layers.Item[sSpaceName].Selection.SelectByPoint(X1,Y1,miSelectionNew,miSearchResultDefault);
        if Map_main.Layers.Item[sSpaceName].Selection.Count <> 0 then
        begin
          MapControl.SetKeyBySelect(sSpaceName);
        end;
      end;
      blnToolUsed:=False;
    end;
  except on E: Exception do
  begin
    ShowMessage(E.Message);
  end;
  end;
end;

{procedure TForm_MainBase.lv_PropertyDblClick(Sender: TObject);
var
  msTableName:string;
begin
  msTableName:=MapControl.sGetTvSelectTableName;
  with TForm_Basic.create(systemDM.Glb_BasicDataOperate,msTableName,'',4,lv_Property) do
  begin
    try
      ShowModal;
    finally
      free;
    end;
  end;
end; }

procedure TForm_MainBase.Map_mainPolyToolUsed(ASender: TObject;
  ToolNum: Smallint; Flags: Integer; const Points: IDispatch; bShift,
  bCtrl: WordBool; var EnableDefault: WordBool);
begin
blnToolUsed:=True;
if Map_Main.CurrentTool=miRulerTool then
   begin
     case Flags of
        miPolyToolBegin:

          begin
            m_distance:=0 ;
            m_MapX:=0;
            m_MapY:=0;
          end;

        miPolyToolend:

          begin
            m_pointsNum:=0;
            stb_Main.SimpleText:='';
          end;
        miPolyToolEndEscaped:
          begin
            m_pointsNum:=0;
            stb_Main.SimpleText:='';
          end;
     end;
  end
  else
    begin
    end;
end;

procedure TForm_MainBase.Map_mainMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
  screenX:single;
  screenY:single;
  m_strDistance:string;
  MapX:double;
  MapY:double;
begin
 //如果是标尺工具
 if map_main.CurrentTool=miRulerTool then
  begin
    m_PointsNum:=m_PointsNum+1;
    if m_PointsNum>=2 then
      begin
           screenX:=x;
           screenY:=y;
           map_main.ConvertCoord (screenX, screenY, MapX, MapY, miScreenToMap);
           map_main.MapUnit:=miUnitKilometer;
           m_distance:=m_distance+map_main.distance(MapX,MapY,m_MapX,m_MapY);

           str(m_distance,m_strDistance);
           m_strDistance:=m_strDistance+'千米';

          //m_statusBar.SimpleText:=m_strDistance;
      end;

      stb_main.SimpleText:=m_strDistance;
      map_main.ConvertCoord (screenX, screenY, m_MapX, m_MapY, miScreenToMap);
    end;
end;
procedure TForm_MainBase.btn_SelectClick(Sender: TObject);
var
  cDataPub:TDataPub;
  cMapInfo:pMapInfo;
  cDataGrid:TGridListView;
  strSql:string;
  iLoop:integer;
  sFieldName:string;
  sFieldType:string;
  adoQue:TADOQuery;
  iForeign:integer;
  sForeignId:string;
  sForeignName:string;
  sForeignTableName:string;
  sForeignFieldType:string;
begin
  if tv_Layer.SelectionCount<>0 then
    cMapInfo:=tv_Layer.Selected.Data
  else
  begin
    Application.MessageBox('请在图层控制树上选择要查询的图层!','提示',MB_OK + MB_ICONINFORMATION);
    exit;
  end;

  strSql:='select * from sys_RapidSelTable where TableName=''' + cMapInfo^.TableName + '''' + ' and SelectFieldName=''' + cb_Condition.itemsvalue[cb_Condition.itemindex] + '''';
  adoQue:=systemDM.Glb_BasicDataOperate.adoGetAdoQuery(strSql);


    sFieldName:=adoQue.fieldbyname('SelectFieldName').AsString;
    sFieldType:=adoQue.fieldbyname('SelectFieldType').AsString;
    iForeign:=adoQue.fieldbyname('IsForeign').AsInteger;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -