Exemple #1
0
void CTrack::Highlight(bool bOn, HDC hDC, bool bHash)
{
	if (!m_pAGDC)
		return;

	m_bIsHighlight = bOn;
	m_bHash = bHash;

	if (!hDC)
		hDC = m_pAGDC->GetHDC();

	CPoint pt[4];
	pt[0] = m_Distort.p[0];
	pt[1] = m_Distort.p[1];
	pt[2] = m_Distort.p[2];
	pt[3] = m_Distort.p[3];

	CAGMatrix Matrix = m_Matrix * m_ViewToDeviceMatrix;

	if (!(m_iWhatCanDo & TR_DRAWASLINE))
	{
		CRect Offset(-1, -1, 0, 0);
		Matrix.Inverse().Transform((CPoint*)&Offset, 2, false);

		pt[0].x += Offset.left;
		pt[0].y += Offset.top;
		pt[1].x += Offset.right;
		pt[1].y += Offset.top;
		pt[2].x += Offset.right;
		pt[2].y += Offset.bottom;
		pt[3].x += Offset.left;
		pt[3].y += Offset.bottom;
	}

	Matrix.Transform(pt[0]);
	Matrix.Transform(pt[1]);
	Matrix.Transform(pt[2]);
	Matrix.Transform(pt[3]);

	// Before drawing the transform border, open up the clipping to include a border pixel
	HRGN hClipRegion = m_pAGDC->SaveClipRegion();
	CRect rClipRect = m_PageRect;	
	rClipRect.InflateRect(1, 1); // Add a border pixel
	rClipRect.InflateRect(H_SIZE, H_SIZE); // Add the tracking handle size
	m_pAGDC->SetClipRect(rClipRect);

	Hline(hDC, pt[0].x, pt[0].y, pt[1].x, pt[1].y, m_bHash);
	Hline(hDC, pt[1].x, pt[1].y, pt[2].x, pt[2].y, m_bHash);
	Hline(hDC, pt[2].x, pt[2].y, pt[3].x, pt[3].y, m_bHash);
	Hline(hDC, pt[3].x, pt[3].y, pt[0].x, pt[0].y, m_bHash);

	m_pAGDC->RestoreClipRegion(hClipRegion);
}
Exemple #2
0
void CTrack::Highlight(bool bOn, HDC hDC, bool bHash)
{
	if (!m_pAGDC)
		return;

	m_bIsHighlight = bOn;
	m_bHash = bHash;

	if (!hDC)
		hDC = m_pAGDC->GetHDC();

	POINT pt[4];
	pt[0] = m_Distort.p[0];
	pt[1] = m_Distort.p[1];
	pt[2] = m_Distort.p[2];
	pt[3] = m_Distort.p[3];

	CAGMatrix Matrix = m_Matrix * m_ViewToDeviceMatrix;

	if (!(m_iWhatCanDo & TR_DRAWASLINE))
	{
		RECT Offset = {-1, -1, 0, 0};
		Matrix.Inverse().Transform((POINT*)&Offset, 2, false);

		pt[0].x += Offset.left;
		pt[0].y += Offset.top;
		pt[1].x += Offset.right;
		pt[1].y += Offset.top;
		pt[2].x += Offset.right;
		pt[2].y += Offset.bottom;
		pt[3].x += Offset.left;
		pt[3].y += Offset.bottom;
	}

	Matrix.Transform(pt[0]);
	Matrix.Transform(pt[1]);
	Matrix.Transform(pt[2]);
	Matrix.Transform(pt[3]);

	// Before drawing the transform border, open up the clipping to include a border pixel
	HRGN hClipRegion = m_pAGDC->SaveClipRegion();
	RECT rClipRect = m_PageRect;	
	::InflateRect(&rClipRect, 1, 1); // Add a border pixel
	m_pAGDC->SetClipRect(rClipRect, false/*bIncludeRawDC*/);

	HlineFlash(hDC, pt[0].x, pt[0].y, pt[1].x, pt[1].y, m_bHash);
	HlineFlash(hDC, pt[1].x, pt[1].y, pt[2].x, pt[2].y, m_bHash);
	HlineFlash(hDC, pt[2].x, pt[2].y, pt[3].x, pt[3].y, m_bHash);
	HlineFlash(hDC, pt[3].x, pt[3].y, pt[0].x, pt[0].y, m_bHash);

	m_pAGDC->RestoreClipRegion(hClipRegion);
}
void CEnvelopeWizard::SetImageSize(CAGSymImage* pImage, POINT* pCenterPoint)
{
	if (!pImage)
		return;

	// The image symbol should be at (0,0) and have a unity matrix
	CRect DestRect = pImage->GetDestRect();
	DestRect.MoveToXY(0,0);
	pImage->SetDestRect(DestRect);

	// Maintain a maximum image size using the symbol's matrix
	CAGMatrix NewMatrix;
	if (DestRect.Width() > m_nMaxImageSize || DestRect.Height() > m_nMaxImageSize)
	{
		int dx = m_nMaxImageSize;
		int dy = m_nMaxImageSize;
		double fScale = ScaleToFit(&dx, &dy, DestRect.Width(), DestRect.Height(), true/*bUseSmallerFactor*/);
		NewMatrix.Scale(fScale, fScale);
		NewMatrix.Transform(DestRect);
	}

	if (pCenterPoint)
		NewMatrix.Translate(pCenterPoint->x - DestRect.Width()/2, pCenterPoint->y - DestRect.Height()/2);

	pImage->SetMatrix(NewMatrix);
}
Exemple #4
0
void CDocWindow::HandleImageRecolor(int x, int y, CImageObject* pObject)
{
	if (pObject == NULL)
		return;


	BITMAPINFOHEADER* pBitmap = pObject->GetDib();
	if (pBitmap != NULL)
	{
		CRect DestRect = pObject->GetDestRect();
		CFloodFill FloodFill;

		CAGMatrix Matrix;
		CPoint pt(x, y);
		if (m_pClientDC)
			m_pClientDC->GetViewToDeviceMatrix().Inverse().Transform(pt);

		double xScale = (double)DibWidth(pBitmap) / DestRect.Width();
		double yScale = (double)DibHeight(pBitmap) / DestRect.Height();
		Matrix.Translate(-DestRect.left, -DestRect.top);
		Matrix.Scale(xScale, yScale, 0, 0);
		Matrix.Transform(pt);

		FloodFill.Fill(pBitmap, &DestRect, pt.x, pt.y, (m_fUsePrimaryColor ? m_PrimaryColor : m_SecondaryColor));
	}

	// Invalidate the image's current location
	InvalidateImage(pObject);

	pObject->SetModified(true);

	//if (pDIBNew)
	//{
	//	pObject->SetDib(pDIBNew);
	//	free(pDIB);
	//}
	//else
	//{
	//	// Adjust the image's matrix
	//	CRect DestRect = pObject->GetDestRect();
	//	CAGMatrix Matrix = pObject->GetMatrix();
	//	Matrix.Transform(DestRect);
	//	Matrix.Scale((bFlipX ? -1 : 1), (bFlipY ? -1 : 1),
	//		(DestRect.left + DestRect.right) / 2,
	//		(DestRect.top + DestRect.bottom) / 2);

	//	pObject->SetMatrix(Matrix);
	//}
}
Exemple #5
0
void CNewDocWizStep1::UpdateSample(int idSample)
{
	HWND hWnd = GetDlgItem(idSample);
	if (!hWnd)
		return;

	// If it is our first time in, initialize the sample rectangle
	if (::IsRectEmpty(&m_SampleRect))
	{
		::GetClientRect(hWnd, &m_SampleRect);
		if (::GetParent(hWnd))
			::MapWindowPoints(hWnd, ::GetParent(hWnd), (LPPOINT)&m_SampleRect.left, 2);
	}

	SIZE DocSize = {(int)(m_Data->m_fWidth * 1000), (int)(m_Data->m_fHeight * 1000)};
	RECT NewRect;
	::SetRect(&NewRect, 0, 0, DocSize.cx, DocSize.cy);
	CAGMatrix Matrix;
	Matrix.ScaleToFit(m_SampleRect, NewRect);
	Matrix.Transform(NewRect);
	::MoveWindow(hWnd, NewRect.left, NewRect.top, WIDTH(NewRect), HEIGHT(NewRect), true/*bRepaint*/);
}
Exemple #6
0
void CTrack::Draw(bool bOn, HDC hDC)
{
	if (!m_pAGDC)
		return;

	m_bIsDrawn = bOn;

	if (!hDC)
		hDC = m_pAGDC->GetHDC();

	POINT pt[4];
	pt[0] = m_Distort.p[0];
	pt[1] = m_Distort.p[1];
	pt[2] = m_Distort.p[2];
	pt[3] = m_Distort.p[3];

	CAGMatrix Matrix = m_Matrix * m_ViewToDeviceMatrix;

	// A trick to draw the selection rectangle outside of a transformed object
	if (!(m_iWhatCanDo & TR_DRAWASLINE))
	{
		RECT Offset = {-1, -1, 0, 0};
		Matrix.Inverse().Transform((POINT*)&Offset, 2, false);

		pt[0].x += Offset.left;
		pt[0].y += Offset.top;
		pt[1].x += Offset.right;
		pt[1].y += Offset.top;
		pt[2].x += Offset.right;
		pt[2].y += Offset.bottom;
		pt[3].x += Offset.left;
		pt[3].y += Offset.bottom;
	}

	Matrix.Transform(pt[0]);
	Matrix.Transform(pt[1]);
	Matrix.Transform(pt[2]);
	Matrix.Transform(pt[3]);

	// Before drawing the transform border, open up the clipping to include a border pixel
	HRGN hClipRegion = m_pAGDC->SaveClipRegion();
	RECT rClipRect = m_PageRect;	
	::InflateRect(&rClipRect, 1, 1); // Add a border pixel
	m_pAGDC->SetClipRect(rClipRect, false/*bIncludeRawDC*/);

	if (m_iWhatCanDo & TR_DRAWASLINE)
	{
		Dline(hDC, pt[0].x, pt[0].y, pt[2].x, pt[2].y, bOn);
	}
	else
	{
		Hline(hDC, pt[0].x, pt[0].y, pt[1].x, pt[1].y, bOn);
		Hline(hDC, pt[1].x, pt[1].y, pt[2].x, pt[2].y, bOn);
		Hline(hDC, pt[2].x, pt[2].y, pt[3].x, pt[3].y, bOn);
		Hline(hDC, pt[3].x, pt[3].y, pt[0].x, pt[0].y, bOn);
	}

	DrawHandles(hDC, bOn, pt);

	m_pAGDC->RestoreClipRegion(hClipRegion);
}