コード例 #1
0
ファイル: symbol.cpp プロジェクト: GimpoByte/nextgismanager
void wxGISSimpleCircleSymbol::Draw(const wxGISGeometry &Geometry, int nLevel)
{
    if (!Geometry.IsOk() || !m_pDisplay)
        return;

    OGRwkbGeometryType eGeomType = wkbFlatten(Geometry.GetType());
    if (eGeomType != wkbMultiPoint)
        return;

    OGREnvelope Env;
    OGRGeometry *pGeom = Geometry;

    OGRMultiPoint* pMPT = (OGRMultiPoint*)pGeom;
    OGRPoint* pCenterPt = (OGRPoint*)pMPT->getGeometryRef(0);
    OGRPoint* pOriginPt = (OGRPoint*)pMPT->getGeometryRef(1);
    double dfRadius = sqrt((pCenterPt->getX() - pOriginPt->getX())*(pCenterPt->getX() - pOriginPt->getX()) + (pCenterPt->getY() - pOriginPt->getY())*(pCenterPt->getY() - pOriginPt->getY()));
    Env.MaxX = pCenterPt->getX() + dfRadius;
    Env.MinX = pCenterPt->getX() - dfRadius;
    Env.MaxY = pCenterPt->getY() + dfRadius;
    Env.MinY = pCenterPt->getY() - dfRadius;

    if (!m_pDisplay->CanDraw(Env))
        return;

    wxCriticalSectionLocker lock(m_pDisplay->GetLock());

    if (!m_pDisplay->CheckDrawAsPoint(Env, m_pLineSymbol->GetWidth()))
    {
        if (!m_pDisplay->DrawCircle(pCenterPt->getX(), pCenterPt->getY(), 0, 0, dfRadius))
        {
            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();
}
コード例 #2
0
ファイル: symbol.cpp プロジェクト: GimpoByte/nextgismanager
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();
}
コード例 #3
0
ファイル: symbol.cpp プロジェクト: GimpoByte/nextgismanager
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();

}
コード例 #4
0
ファイル: mapview.cpp プロジェクト: Mileslee/wxgis
void wxGISMapView::DrawGeometry(const wxGISGeometry &Geometry, WXGISRGBA stFillColour, WXGISRGBA stLineColour, double dfLineWidth)
{
    wxCHECK_RET(Geometry.IsOk(), wxT("Input geometry is not valid"));

	OGRwkbGeometryType type = wkbFlatten(Geometry.GetType());
	switch(type)
	{
	case wkbPoint:
	case wkbMultiPoint:
	    m_pGISDisplay->SetColor(enumGISDrawStylePoint, stLineColour);
	    m_pGISDisplay->SetColor(enumGISDrawStyleOutline, stLineColour);
	    m_pGISDisplay->SetColor(enumGISDrawStyleFill, stFillColour);
		m_pGISDisplay->SetLineCap(CAIRO_LINE_CAP_ROUND);
		m_pGISDisplay->SetLineWidth(dfLineWidth);
		m_pGISDisplay->SetPointRadius(2.0);
		break;
	case wkbLineString:
	case wkbLinearRing:
	case wkbMultiLineString:
	    m_pGISDisplay->SetColor(enumGISDrawStylePoint, stFillColour);
	    m_pGISDisplay->SetColor(enumGISDrawStyleOutline, stFillColour);
	    m_pGISDisplay->SetColor(enumGISDrawStyleFill, stFillColour);
		m_pGISDisplay->SetLineCap(CAIRO_LINE_CAP_BUTT);
		m_pGISDisplay->SetLineWidth(2.0);
		break;
	case wkbMultiPolygon:
	case wkbPolygon:
	    m_pGISDisplay->SetColor(enumGISDrawStyleOutline, stLineColour);
	    m_pGISDisplay->SetColor(enumGISDrawStyleFill, stFillColour);
		m_pGISDisplay->SetLineCap(CAIRO_LINE_CAP_BUTT);
		m_pGISDisplay->SetLineWidth(dfLineWidth);
		break;
	case wkbGeometryCollection:
		break;
	default:
	case wkbUnknown:
	case wkbNone:
		break;
	}
	m_pGISDisplay->DrawGeometry( Geometry );
}
コード例 #5
0
ファイル: symbol.cpp プロジェクト: GimpoByte/nextgismanager
void wxGISSimpleCollectionSymbol::Draw(const wxGISGeometry &Geometry, int nLevel)
{
    if(!Geometry.IsOk() ||!m_pDisplay)
        return;

    if (!Geometry.IsOk())
        return;

    switch (wkbFlatten(Geometry.GetType()))
    {
    case wkbMultiPoint:
    case wkbPoint:
        m_pMarkerSymbol->Draw(Geometry);
        break;
    case wkbMultiPolygon:
    case wkbPolygon:
        m_pFillSymbol->Draw(Geometry);
        break;
    case wkbMultiLineString:
    case wkbLineString:
        m_pLineSymbol->Draw(Geometry);
        break;
    case wkbGeometryCollection:
        {
            OGRGeometryCollection* pOGRGeometryCollection = (OGRGeometryCollection*)Geometry.operator OGRGeometry *();
            for (int i = 0; i < pOGRGeometryCollection->getNumGeometries(); ++i)
            {
                wxGISGeometry CollectionGeom(pOGRGeometryCollection->getGeometryRef(i), false);
                Draw(CollectionGeom, nLevel);
            }
        }
        break;
    case wkbLinearRing:
    case wkbUnknown:
    case wkbNone:
    default:
        break;
    }
}
コード例 #6
0
ファイル: symbol.cpp プロジェクト: GimpoByte/nextgismanager
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();
    }
}
コード例 #7
0
ファイル: symbol.cpp プロジェクト: GimpoByte/nextgismanager
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();
}