Example #1
0
void wxGISDisplay::SetDeviceFrame(wxRect &rc)
{
	m_oDeviceFrameRect = rc;
	if(m_oDeviceFrameRect.GetWidth() % 2 != 0)
		m_oDeviceFrameRect.SetWidth(m_oDeviceFrameRect.GetWidth() + 1);
	if(m_oDeviceFrameRect.GetHeight() % 2 != 0)
		m_oDeviceFrameRect.SetHeight(m_oDeviceFrameRect.GetHeight() + 1);

	m_dFrameRatio = double(m_oDeviceFrameRect.GetWidth()) / m_oDeviceFrameRect.GetHeight();

	m_CurrentBounds = m_RealBounds;

	SetEnvelopeRatio(m_CurrentBounds, m_dFrameRatio);
	m_dRotatedBoundsCenterX = m_CurrentBounds.MinX + (m_CurrentBounds.MaxX - m_CurrentBounds.MinX) / 2;
	m_dRotatedBoundsCenterY = m_CurrentBounds.MinY + (m_CurrentBounds.MaxY - m_CurrentBounds.MinY) / 2;
	m_CurrentBoundsRotated = m_CurrentBounds;
	if(!IsDoubleEquil(m_dAngleRad, 0.0))
	{
		RotateEnvelope(m_CurrentBoundsRotated, m_dAngleRad, m_dRotatedBoundsCenterX, m_dRotatedBoundsCenterY);
		SetEnvelopeRatio(m_CurrentBoundsRotated, m_dFrameRatio);//test
	}
	m_CurrentBoundsX8 = m_CurrentBoundsRotated;
	IncreaseEnvelope(m_CurrentBoundsX8, 8);

    cairo_destroy (m_cr_tmp);
    cairo_surface_destroy (m_surface_tmp);

	m_surface_tmp = cairo_image_surface_create (CAIRO_FORMAT_RGB24, m_oDeviceFrameRect.GetWidth(), m_oDeviceFrameRect.GetHeight());
	m_cr_tmp = cairo_create (m_surface_tmp);


	//compute current transform matrix
	InitTransformMatrix();
}
Example #2
0
bool wxGISDisplay::CanDraw(OGREnvelope &Env)
{
	if(!IsDoubleEquil(m_dAngleRad, 0.0))
	{
		RotateEnvelope(Env, -m_dAngleRad, m_dRotatedBoundsCenterX, m_dRotatedBoundsCenterY);
	}

	return Env.Contains(m_CurrentBoundsRotated) || m_CurrentBoundsRotated.Contains(Env) || Env.Intersects(m_CurrentBoundsRotated);
}
Example #3
0
OGREnvelope wxGISMapView::GetFullExtent(void)
{
	OGREnvelope OutputEnv;
	if(!IsDoubleEquil(m_dCurrentAngle, 0.0))
	{
		OutputEnv = m_FullExtent;
		double dCenterX = m_FullExtent.MinX + (m_FullExtent.MaxX - m_FullExtent.MinX) / 2;
		double dCenterY = m_FullExtent.MinY + (m_FullExtent.MaxY - m_FullExtent.MinY) / 2;
		RotateEnvelope(OutputEnv, m_dCurrentAngle, dCenterX, dCenterY);
		IncreaseEnvelope(OutputEnv, 0.1);
	}
	else
		OutputEnv = wxGISMap::GetFullExtent();
	return OutputEnv;
}
Example #4
0
bool wxGISDisplay::CheckDrawAsPoint(const OGREnvelope &Envelope, double dfLineWidth, bool bIsRing, double dOffsetX, double dOffsetY, bool bCheckEnvelope)
{
	OGREnvelope TestEnv;
	TestEnv = Envelope;
	if(!IsDoubleEquil(m_dAngleRad, 0.0))
	{
		RotateEnvelope(TestEnv, -m_dAngleRad, m_dRotatedBoundsCenterX, m_dRotatedBoundsCenterY);
	}

	if(bCheckEnvelope && !m_CurrentBoundsRotated.Intersects(TestEnv))
		return true;

	double EnvWidth = Envelope.MaxX - Envelope.MinX;
	double EnvHeight = Envelope.MaxY - Envelope.MinY;

	World2DCDist(&EnvWidth, &EnvHeight);
	double dfR = (fabs(EnvWidth) + fabs(EnvHeight)) * .5;
    if (dfR <= MINPOLYDRAWAREA)
	{
	    if(bIsRing)
        {
            SetLineWidth( dfLineWidth + dfLineWidth );
        }
        else
        {
            SetLineWidth( dfLineWidth );
        }

        if (dfR >= MINPOLYAREA)
		{
            wxCriticalSectionLocker locker(m_CritSect);
			cairo_move_to(m_saLayerCaches[m_nCurrentLayer].pCairoContext, Envelope.MinX + dOffsetX, Envelope.MinY + dOffsetY);
			cairo_line_to(m_saLayerCaches[m_nCurrentLayer].pCairoContext, Envelope.MaxX + dOffsetX, Envelope.MaxY + dOffsetY);
		}
        else
        {
			DrawPointFast(Envelope.MinX, Envelope.MinY, dOffsetX, dOffsetY);
        }



        SetLineCap(CAIRO_LINE_CAP_ROUND);
		return true;
	}
	return false;
}
Example #5
0
void wxGISDisplay::SetRotate(double dAngleRad)
{
	m_dAngleRad = dAngleRad;
    //for rotate panning & zooming
	m_CurrentBoundsRotated = m_CurrentBounds;
	m_dRotatedBoundsCenterX = m_CurrentBoundsRotated.MinX + (m_CurrentBoundsRotated.MaxX - m_CurrentBoundsRotated.MinX) / 2;
	m_dRotatedBoundsCenterY = m_CurrentBoundsRotated.MinY + (m_CurrentBoundsRotated.MaxY - m_CurrentBoundsRotated.MinY) / 2;
	if(!IsDoubleEquil(m_dAngleRad, 0.0))
	{
		RotateEnvelope(m_CurrentBoundsRotated, m_dAngleRad, m_dRotatedBoundsCenterX, m_dRotatedBoundsCenterY);
		SetEnvelopeRatio(m_CurrentBoundsRotated, m_dFrameRatio);//test
	}
	m_CurrentBoundsX8 = m_CurrentBoundsRotated;
	IncreaseEnvelope(m_CurrentBoundsX8, 8);

	//compute current transform matrix
	InitTransformMatrix();

	SetAllCachesDerty(true);
}
Example #6
0
void wxGISDisplay::SetBounds(const OGREnvelope& Bounds)
{
	//update bounds to frame ratio
	m_RealBounds = Bounds;
	m_CurrentBounds = m_RealBounds;

	SetEnvelopeRatio(m_CurrentBounds, m_dFrameRatio);
	m_dRotatedBoundsCenterX = m_CurrentBounds.MinX + (m_CurrentBounds.MaxX - m_CurrentBounds.MinX) / 2;
	m_dRotatedBoundsCenterY = m_CurrentBounds.MinY + (m_CurrentBounds.MaxY - m_CurrentBounds.MinY) / 2;
	m_CurrentBoundsRotated = m_CurrentBounds;
	if(!IsDoubleEquil(m_dAngleRad, 0.0))
	{
		RotateEnvelope(m_CurrentBoundsRotated, m_dAngleRad, m_dRotatedBoundsCenterX, m_dRotatedBoundsCenterY);
		SetEnvelopeRatio(m_CurrentBoundsRotated, m_dFrameRatio);//test
	}
	m_CurrentBoundsX8 = m_CurrentBoundsRotated;
	IncreaseEnvelope(m_CurrentBoundsX8, 8);

	SetAllCachesDerty(true);
	//compute current transform matrix
	InitTransformMatrix();
}
bool wxGISDrawingLayer::Draw(wxGISEnumDrawPhase DrawPhase, ITrackCancel* const pTrackCancel)
{
    wxCHECK_MSG(m_pDisplay, false, wxT("Display pointer is NULL"));

    wxCriticalSectionLocker lock(m_CritSect);

    OGREnvelope stDisplayExtentRotated = m_pDisplay->GetBounds(true);
    OGREnvelope stFeatureDatasetExtentRotated = m_oLayerExtent;

    //rotate featureclass extent
    if (!IsDoubleEquil(m_pDisplay->GetRotate(), 0.0))
    {
        wxRealPoint dfCenter = m_pDisplay->GetBoundsCenter();
        RotateEnvelope(stFeatureDatasetExtentRotated, m_pDisplay->GetRotate(), dfCenter.x, dfCenter.y);//dCenterX, dCenterY);
    }

    //if envelopes don't intersect exit
    if (!stDisplayExtentRotated.Intersects(stFeatureDatasetExtentRotated))
        return false;

    //get intersect envelope to fill vector data
    OGREnvelope stDrawBounds = stDisplayExtentRotated;
    stDrawBounds.Intersect(stFeatureDatasetExtentRotated);
    if (!stDrawBounds.IsInit())
        return false;

    IProgressor* pProgress = NULL;
    if (NULL != pTrackCancel)
    {
        pProgress = pTrackCancel->GetProgressor();
    }

    if (NULL != pProgress)
    {
        pProgress->SetRange(m_aoShapes.size());
    }

    //draw shapes
    for (size_t i = 0; i < m_aoShapes.size(); ++i)
    {
        if (NULL != pProgress)
        {
            pProgress->SetValue(i);
        }

        if (pTrackCancel != NULL && !pTrackCancel->Continue())
            return true;
        if (m_aoShapes[i] != NULL)
        {
            m_aoShapes[i]->Draw(m_pDisplay);
        }
    }

    //draw enumGISShapeStateSelected

    //draw enumGISShapeStateRotated

    //draw enumGISShapeStatePoints

    return true;
}