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

📄 show.cpp

📁 利用vc开发gis系统有用的可以下一下哈欢迎大家使用
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "show.h"
#include "SetLineStyle.h"
#include "SetBrushStyle.h"
#include "main.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm2::FormPaint(TObject *Sender)
{
 GISRECT gisRect;
 gisRect.x1 =m_GisVector.m_gisFileHeader.giMinX ;
 gisRect.x2 =m_GisVector.m_gisFileHeader.giMaxX ;
 gisRect.y1 =m_GisVector.m_gisFileHeader.giMinY ;
 gisRect.y2 =m_GisVector.m_gisFileHeader.giMaxY ;
 TRect dest(0,0,Width,Height);
 m_GisVector.Draw (Canvas,gisRect,dest);
}
//---------------------------------------------------------------------------
void __fastcall TForm2::FormResize(TObject *Sender)
{
 Invalidate();
}
//---------------------------------------------------------------------------
void __fastcall TForm2::FormClose(TObject *Sender, TCloseAction &Action)
{
 Action=caFree;
}
//---------------------------------------------------------------------------
void __fastcall TForm2::BitmapSymClick(TObject *Sender)
{
  if(m_GisVector.m_gisFileHeader.giType != GIS_POLYGON)
    return;
  if(OpenDialog1->Execute())
  {
    m_GisVector.SetBitmapBrush (OpenDialog1->FileName);
  }
}
//---------------------------------------------------------------------------
void __fastcall TForm2::FormMouseDown(TObject *Sender, TMouseButton Button,
      TShiftState Shift, int X, int Y)
{
  int oldSelectID = m_GisVector.m_nSelectID;
  m_GisVector.SelectPolygon(TPoint(X,Y));
  LPGISPOLYGON polygon;
  if(m_GisVector.m_nSelectID >= 0) //如果点不在任何多边形之中,则直接退出
  {
    polygon= (GISPOLYGON*)(m_GisVector.m_lpPolygonList->Items[m_GisVector.m_nSelectID]);
    TRect invalRect = m_GisVector.GisRectToTRect(polygon->outRect);
    //更新现选择的多边形
    InvalidateRect(Handle,&invalRect, true);
  }

  if(oldSelectID >= 0)
  {
    //更新原选择多边形
    polygon = (GISPOLYGON*)(m_GisVector.m_lpPolygonList->Items[oldSelectID]);
    TRect invalRect = m_GisVector.GisRectToTRect(polygon->outRect);
    InvalidateRect(Handle,&invalRect, true);
  }
}
//---------------------------------------------------------------------------
void __fastcall TForm2::LineStyleClick(TObject *Sender)
{
  if(m_GisVector.m_nSelectID <= 0)
    return;
  LPGISPOLYGON polygon = (GISPOLYGON*)(m_GisVector.m_lpPolygonList->Items[m_GisVector.m_nSelectID]);
  TLineStyleDlg *LineStyleDlg = new TLineStyleDlg(this);
  LineStyleDlg->Image->Canvas->Pen->Style = polygon->pPen->Style;
  LineStyleDlg->ShowModal ();
  if(LineStyleDlg->ModalResult == mrOk)
  {
    polygon->pPen->Style = LineStyleDlg->Image->Canvas->Pen->Style;
    polygon->pPen->Width = LineStyleDlg->Image->Canvas->Pen->Width;
    polygon->pPen->Color = LineStyleDlg->Image->Canvas->Pen->Color;
  }
  TRect invalRect = m_GisVector.GisRectToTRect(polygon->outRect);
  InvalidateRect(Handle,&invalRect, true);
}
//---------------------------------------------------------------------------
void __fastcall TForm2::FillStyleClick(TObject *Sender)
{
  if(m_GisVector.m_nSelectID <= 0)
    return;
  LPGISPOLYGON polygon = (GISPOLYGON*)(m_GisVector.m_lpPolygonList->Items[m_GisVector.m_nSelectID]);
  TBrushStyleDlg *PolygonStyDlg = NULL;
  PolygonStyDlg = new TBrushStyleDlg(this);
  PolygonStyDlg->Image->Canvas->Brush->Style = polygon->pBrush->Style ;
  PolygonStyDlg->Image->Canvas->Brush->Color = polygon->pBrush->Color;
  PolygonStyDlg->ShowModal();
  if(PolygonStyDlg->ModalResult == mrOk)
  {
    polygon->pBrush->Style = PolygonStyDlg->Image->Canvas->Brush->Style;
    polygon->pBrush->Color = PolygonStyDlg->Image->Canvas->Brush->Color;
  }
  TRect invalRect = m_GisVector.GisRectToTRect(polygon->outRect);
  InvalidateRect(Handle,&invalRect, true);
}
//---------------------------------------------------------------------------
void __fastcall TForm2::OpenClick(TObject *Sender)
{
  Form1->OpenClick(Sender);
}
//---------------------------------------------------------------------------
void __fastcall TForm2::CloseWndClick(TObject *Sender)
{
  Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm2::ExitAppClick(TObject *Sender)
{
  Form1->ExitClick(Sender);
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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