void wxGISSimpleMarkerSymbol::Draw(const wxGISGeometry &Geometry, int nLevel) { if(!Geometry.IsOk() ||!m_pDisplay) return; OGRwkbGeometryType eGeomType = wkbFlatten(Geometry.GetType()); if(eGeomType != wkbPoint && eGeomType != wkbMultiPoint) return; OGREnvelope Env = Geometry.GetEnvelope(); if(!m_pDisplay->CanDraw(Env)) return; OGRGeometry *pGeom = Geometry; if(eGeomType == wkbMultiPoint) { OGRGeometryCollection* pOGRGeometryCollection = (OGRGeometryCollection*)pGeom; for(int i = 0; i < pOGRGeometryCollection->getNumGeometries(); ++i) Draw(wxGISGeometry(pOGRGeometryCollection->getGeometryRef(i), false)); return; } wxCriticalSectionLocker lock(m_pDisplay->GetLock()); OGRPoint* pPoint = (OGRPoint*)pGeom; if(m_dfOutlineSize) { if(!m_pDisplay->DrawPointFast(pPoint->getX(), pPoint->getY())) { return; } m_pDisplay->SetColor(m_OutlineColor); m_pDisplay->SetLineWidth( m_dfSize + m_dfOutlineSize + m_dfOutlineSize); m_pDisplay->Stroke(); } if(!m_pDisplay->DrawPointFast(pPoint->getX(), pPoint->getY())) { return; } m_pDisplay->SetColor(m_Color); m_pDisplay->SetLineWidth( m_dfSize ); m_pDisplay->SetLineCap(CAIRO_LINE_CAP_ROUND); m_pDisplay->Stroke(); }
void wxGISSimpleEllipseSymbol::Draw(const wxGISGeometry &Geometry, int nLevel) { if (!Geometry.IsOk() || !m_pDisplay) return; OGRwkbGeometryType eGeomType = wkbFlatten(Geometry.GetType()); if (eGeomType != wkbPolygon) return; OGREnvelope Env = Geometry.GetEnvelope(); if (!m_pDisplay->CanDraw(Env)) return; wxCriticalSectionLocker lock(m_pDisplay->GetLock()); if (!m_pDisplay->CheckDrawAsPoint(Env, m_pLineSymbol->GetWidth())) { if (!m_pDisplay->DrawEllipse(Env.MinX, Env.MinY, 0, 0, Env.MaxX - Env.MinX, Env.MaxY - Env.MinY)) { return; } if (m_Color.Alpha() > 0) { switch (m_eFillRule) { case enumGISFillRuleWinding: m_pDisplay->SetFillRule(CAIRO_FILL_RULE_WINDING); break; case enumGISFillRuleOdd: m_pDisplay->SetFillRule(CAIRO_FILL_RULE_EVEN_ODD); break; } m_pDisplay->SetColor(m_Color); m_pDisplay->FillPreserve(); } } m_pLineSymbol->SetStyleToDisplay(); m_pDisplay->Stroke(); }
void wxGISSimpleLineSymbol::Draw(const wxGISGeometry &Geometry, int nLevel) { if(!Geometry.IsOk() || !m_pDisplay) return; OGRwkbGeometryType eGeomType = wkbFlatten(Geometry.GetType()); if(eGeomType != wkbLineString && eGeomType != wkbLinearRing && eGeomType != wkbMultiLineString) return; OGREnvelope Env = Geometry.GetEnvelope(); if(!m_pDisplay->CanDraw(Env)) return; wxCriticalSectionLocker lock(m_pDisplay->GetLock()); OGRGeometry *pGeom = Geometry; if (eGeomType == wkbMultiLineString) { OGRGeometryCollection* pOGRGeometryCollection = (OGRGeometryCollection*)pGeom; for(int i = 0; i < pOGRGeometryCollection->getNumGeometries(); ++i) Draw(wxGISGeometry(pOGRGeometryCollection->getGeometryRef(i), false)); } else { OGRLineString* pLine = (OGRLineString*)pGeom; int nPointCount = pLine->getNumPoints(); if (!m_pDisplay->CheckDrawAsPoint(Env, m_dfWidth, false, 0, 0, false)) { if(!DrawPreserved(pLine)) return; SetStyleToDisplay(); } else { SetLimitStyleToDisplay(); } m_pDisplay->Stroke(); } }
void wxAxIdentifyView::Identify(wxGISMapView* pMapView, wxGISGeometry &GeometryBounds) { m_pMapView = pMapView; //if(!m_pMapView)//TODO: add/remove layer map events connection point //{ // wxWindow* pWnd = m_pApp->GetRegisteredWindowByType(wxCLASSINFO(wxGISMapView)); // m_pMapView = dynamic_cast<wxGISMapView*>(pWnd); //} if(!m_pMapView) return; wxBusyCursor wait; wxGISSpatialReference SpaRef = m_pMapView->GetSpatialReference(); double dfWidth(3), dfHeight(3); wxGISAppConfig oConfig = GetConfig(); if(oConfig.IsOk()) { dfWidth = oConfig.ReadDouble(enumGISHKCU, wxString(wxT("wxGISCommon/identify/search_width")), dfWidth); dfHeight = oConfig.ReadDouble(enumGISHKCU, wxString(wxT("wxGISCommon/identify/search_height")), dfHeight); } if(m_pMapView->GetDisplay()) { m_pMapView->GetDisplay()->DC2WorldDist(&dfWidth, &dfHeight); dfWidth = std::fabs(dfWidth); dfHeight = std::fabs(dfHeight); } OGREnvelope Env = GeometryBounds.GetEnvelope(); bool bChanged(false); //if we got a small envelope or it's a point if(Env.MaxX - Env.MinX < dfWidth) { Env.MinX -= dfWidth; Env.MaxX += dfWidth; bChanged = true; } if(Env.MaxY - Env.MinY < dfHeight) { Env.MinY -= dfHeight; Env.MaxY += dfHeight; bChanged = true; } if(bChanged) { GeometryBounds = EnvelopeToGeometry(Env, SpaRef); } OGRPoint *pt = GeometryBounds.GetCentroid(); int nSelection = m_LayerChoice->GetSelection(); wxVector<FILLTREEDATA> data; switch(nSelection) { case 0://get top layer //TODO: check group layer for (size_t i = m_pMapView->GetLayerCount() - 1; i >= 0; --i) { wxGISLayer* const pLayer = m_pMapView->GetLayerByIndex(i); if (NULL == pLayer) { continue; } else if (pLayer->GetType() == enumGISFeatureDataset || pLayer->GetType() == enumGISRasterDataset) { FILLTREEDATA stdata = { pLayer, wxNullSpatialTreeCursor }; data.push_back(stdata); break; } } break; case 1://get all layers //TODO: check group layer for(size_t i = 0; i < m_pMapView->GetLayerCount(); ++i) { wxGISLayer* const pLayer = m_pMapView->GetLayerByIndex(i); if (NULL == pLayer) { continue; } else if (pLayer->GetType() == enumGISFeatureDataset || pLayer->GetType() == enumGISRasterDataset) { FILLTREEDATA stdata = { pLayer, wxNullSpatialTreeCursor }; data.push_back(stdata); } } break; default: return; }; for(size_t i = 0; i < data.size(); ++i) { wxGISEnumDatasetType eType = data[i].pLayer->GetType(); switch(eType) { case enumGISFeatureDataset: { wxGISFeatureLayer* pFLayer = dynamic_cast<wxGISFeatureLayer*>(data[i].pLayer); if(!pFLayer) return; wxGISSpatialTreeCursor Cursor = pFLayer->Idetify(GeometryBounds); wxGISSpatialTreeCursor::const_iterator iter; for(iter = Cursor.begin(); iter != Cursor.end(); ++iter) { wxGISSpatialTreeData *current = *iter; if(current) { //flash on map wxGISGeometry Geom = current->GetGeometry(); if (Geom.IsOk()) { wxGISSymbol* pSymbol = GetDrawSymbol(Geom.GetType()); m_pMapView->AddFlashGeometry(Geom, pSymbol); } } } m_pMapView->StartFlashing(); data[i].Cursor = Cursor; } break; default: break; }; } //fill IdentifyDlg m_pFeatureDetailsPanel->Clear(true); m_pFeatureDetailsPanel->SetClickPositionText(pt); FillTree(data); OGRGeometryFactory::destroyGeometry(pt); }
void wxGISSimpleFillSymbol::Draw(const wxGISGeometry &Geometry, int nLevel) { if(!Geometry.IsOk() || !m_pDisplay) return; OGRwkbGeometryType eGeomType = wkbFlatten(Geometry.GetType()); if(eGeomType != wkbPolygon && eGeomType != wkbMultiPolygon) return; OGREnvelope Env = Geometry.GetEnvelope(); if(!m_pDisplay->CanDraw(Env)) return; wxCriticalSectionLocker lock(m_pDisplay->GetLock()); if(!m_pDisplay->CheckDrawAsPoint(Env, m_pLineSymbol->GetWidth())) { OGRGeometry *pGeom = Geometry; if(eGeomType == wkbMultiPolygon) { OGRGeometryCollection* pOGRGeometryCollection = (OGRGeometryCollection*)pGeom; for(int i = 0; i < pOGRGeometryCollection->getNumGeometries(); ++i) Draw(wxGISGeometry(pOGRGeometryCollection->getGeometryRef(i), false)); return; } OGRPolygon* pPolygon = (OGRPolygon*)pGeom; const OGRLinearRing *pRing = pPolygon->getExteriorRing(); if(!m_pLineSymbol->DrawPreserved((OGRLineString*)pRing, true)) { return; } int nNumInteriorRings = pPolygon->getNumInteriorRings(); for(int nPart = 0; nPart < nNumInteriorRings; ++nPart) { pRing = pPolygon->getInteriorRing(nPart); OGREnvelope IntEnv; pRing->getEnvelope(&IntEnv); if(!m_pDisplay->CheckDrawAsPoint(IntEnv, m_pLineSymbol->GetWidth())) { m_pLineSymbol->DrawPreserved((OGRLineString*)pRing, true); } } if(m_Color.Alpha() > 0) { switch(m_eFillRule) { case enumGISFillRuleWinding: m_pDisplay->SetFillRule( CAIRO_FILL_RULE_WINDING ); break; case enumGISFillRuleOdd: m_pDisplay->SetFillRule( CAIRO_FILL_RULE_EVEN_ODD ); break; } m_pDisplay->SetColor(m_Color); m_pDisplay->FillPreserve(); } m_pLineSymbol->SetStyleToDisplay(); } else { m_pLineSymbol->SetLimitStyleToDisplay(); } m_pDisplay->Stroke(); }