Exemple #1
0
BOOL CDRFilter::AddAttributesToArrowheadPath(NodePath *P, DocColour *Col, INT32 LineWidth,
		LineCapType Cap, JointType Join)
{
	if(P->InkPath.IsFilled)
	{
		// it's a filled path, so it need to be filled with the colour and have no line
		// colour
		SetPathFilled(TRUE);
		if(!SetLineColour(DocColour(COLOUR_TRANS)) || !SetFillColour(*Col))
			return FALSE;
	} else {
		// it's not a filled colour, so don't fill it and stroke it with the line width and colour
		if(!SetLineColour(*Col) || !SetLineWidth(LineWidth) || !SetLineCap(Cap) || !SetJoinType(Join))
			return FALSE;
	}

	// apply the attributes to the object
	// If not filled, then set the ignore bit on the fill attribute.
//	if (P->InkPath.IsFilled == FALSE)
//		CurrentAttrs[ATTR_FILLGEOMETRY].Ignore = TRUE;
//	else
		CurrentAttrs[ATTR_FILLGEOMETRY].Ignore = FALSE;

	// Add attributes to the path, if they are different from the default...
	BOOL Result = AttributeManager::ApplyBasedOnDefaults(P, CurrentAttrs);

	//	DeleteCurrentAttrs();
 	//	SetUpCurrentAttrs();

	// Enable the fill attribute again
	CurrentAttrs[ATTR_FILLGEOMETRY].Ignore = FALSE;

	return Result;
}
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;
}
Exemple #3
0
BOOL CDRFilter::SetLineAttr(cdrfOffsetHeader *Object)
{
	if(Version == CDRVERSION_3)
	{
		return SetLineAttr3(Object);
	}
		
	// find the reference...
	DWORD *pReference = (DWORD *)FindDataInObject(Object, cdrfOBJOFFSETTYPE_LINE);

	// if the pointer to the reference is zero, then the reference is probably
	// within some random style definition
	if(pReference == 0)
	{
		// OK, try and find a style number within the style reference
		WORD *pStyleReference = (WORD *)FindDataInObject(Object, cdrfOBJOFFSETTYPE_STYLE);

		if(pStyleReference != 0)
		{
			// OK, see if we can find a the style...
			cdrfStyle *pStyle;
			INT32 StyleSize;

			if((pStyle = (cdrfStyle *)Styles.Find(*pStyleReference, &StyleSize)) != 0)
			{
				// OK, got a style... now find a fill reference within it
				pReference = (DWORD *)FindDataInObject(&pStyle->Header, cdrfSTYLEOFFSETTYPE_OUTLINE);
			}
		}
	}
	
	cdrfOutline *Out;
	INT32 OutSize;
	
	if(pReference == 0 || (Out = (cdrfOutline *)Outlines.Find(*pReference, &OutSize)) == 0
			|| OutSize < sizeof(cdrfOutline))
	{
		// if no outline data, or outline definitions couldn't be found, or outline
		// definition is too small, set up the default line attributes
		if(!SetLineWidth(cdrfOUTLINE_DEFAULT_WIDTH))
			return FALSE;

	PColourCMYK cmyk;
	cmyk.Cyan = cmyk.Magenta = cmyk.Yellow = 0;
	cmyk.Key = 255;

	DocColour Col;
	Col.SetCMYKValue(&cmyk);
	
		if(!SetLineColour(Col))
			return FALSE;

		return TRUE;
	}

	// check that this thingy should have an outline
	if((CDRDATA_WORD(Out->Flags) & cdrfOUTLINEFLAGS_NOOUTLINE) != 0)
	{
		if (!SetLineColour(DocColour(COLOUR_TRANS)))
			return FALSE;

		return TRUE;
	}

	// convert the line colour
	DocColour Col;
	ConvertColour(&Out->Colour, &Col);

	// find the line width
	INT32 LineWidth = CDRDATA_WORD(Out->LineThickness) * CDRCOORDS_TO_MILLIPOINTS;

	if(LineWidth > MAX_LINE_WIDTH)
		LineWidth = MAX_LINE_WIDTH;
	
	// find the join type
	JointType JType;
	switch(CDRDATA_WORD(Out->JoinStyle))
	{
		case cdrfJOINSTYLE_SQUARE:	JType = MitreJoin;		break;
		case cdrfJOINSTYLE_ROUNDED:	JType = RoundJoin;		break;
		default:
		case cdrfJOINSTYLE_BEVEL:	JType = BevelledJoin;	break;
	}
	
	// set the cap style
	LineCapType CType;
	switch(CDRDATA_WORD(Out->EndStyle))
	{
		case cdrfENDSTYLE_BUTT:		CType = LineCapButt;	break;
		case cdrfENDSTYLE_ROUNDED:	CType = LineCapRound;	break;
		default:
		case cdrfENDSTYLE_SQUARE:	CType = LineCapSquare;	break;

	}

	// set the dash pattern
	DashRec Dash;
	DashElement DashArray[cdrfMAX_DASH_ELEMENTS];
	if(CDRDATA_WORD(Out->NDashSegments) > 0 && (CDRDATA_WORD(Out->Flags) & cdrfOUTLINEFLAGS_NODASH) == 0)
	{
		// set a dash pattern
		INT32 NSeg = CDRDATA_WORD(Out->NDashSegments);
		if(NSeg > cdrfMAX_DASH_ELEMENTS)
			NSeg = cdrfMAX_DASH_ELEMENTS;

		INT32 l;
		for(l = 0; l < NSeg; l++)
		{
			DashArray[l] = CDRDATA_WORD(Out->DashSegments[l]) * LineWidth;
		}

		Dash.Elements = NSeg;
		Dash.DashStart = 0;
		Dash.ElementData = DashArray;

		Dash.LineWidth = LineWidth;
		Dash.ScaleWithLineWidth = TRUE;
		Dash.DashID = -1;
	}
	else
	{
		// no dash pattern
		Dash = SD_SOLID;
	}

	// set the attributes
	if(!SetLineWidth(LineWidth) || !SetLineColour(Col) || !SetJoinType(JType)
			|| !SetLineCap(CType) || !SetDashPattern(Dash))
		return FALSE;

	// check for arrowheads
	if(CDRDATA_DWORD(Out->StartArrowReference) != 0 || CDRDATA_DWORD(Out->EndArrowReference) != 0)
	{
		// apply the attributes to the object
		// If not filled, then set the ignore bit on the fill attribute.
		if (ObjFilled == FALSE)
			CurrentAttrs[ATTR_FILLGEOMETRY].Ignore = TRUE;

		// Add attributes to the path, if they are different from the default...
		AttributeManager::ApplyBasedOnDefaults(pMadeNode, CurrentAttrs);

	//	DeleteCurrentAttrs();
 	//	SetUpCurrentAttrs();

		// Enable the fill attribute again
		CurrentAttrs[ATTR_FILLGEOMETRY].Ignore = FALSE;

		// ensure that the attributes won't be applied again
		AttrsAlreadyApplied = TRUE;

		// apply arrow heads to the path
		AddArrowheadsToPath(CDRDATA_DWORD(Out->StartArrowReference), CDRDATA_DWORD(Out->EndArrowReference),
				&Col, LineWidth, CType, JType);
	}

	return TRUE;
}
Exemple #4
0
BOOL CDRFilter::SetLineAttr3(cdrfOffsetHeader *Object)
{
	cdrfOutlineV3 *Out = (cdrfOutlineV3 *)FindDataInObject(Object, cdrfOBJOFFSETTYPE_LINE);
	
	if(Out == 0)
	{
		// if no outline data, or outline definitions couldn't be found, or outline
		// definition is too small, set up the default line attributes
		if(!SetLineWidth(cdrfOUTLINE_DEFAULT_WIDTH))
			return FALSE;

		PColourCMYK cmyk;
		cmyk.Cyan = cmyk.Magenta = cmyk.Yellow = 0;
		cmyk.Key = 255;

		DocColour Col;
		Col.SetCMYKValue(&cmyk);
	
		if(!SetLineColour(Col))
			return FALSE;

		return TRUE;
	}

	// check that this thingy should have an outline
	if((Out->Flags & cdrfOUTLINEFLAGSV3_STROKED) == 0)
	{
		if (!SetLineColour(DocColour(COLOUR_TRANS)))
			return FALSE;

		return TRUE;
	}

	// convert the line colour
	DocColour Col;
	ConvertColour((cdrfColour *)&Out->Colour, &Col);

	// find the line width
	INT32 LineWidth = CDRDATA_WORD(Out->LineThickness) * CDRCOORDS_TO_MILLIPOINTS;

	if(LineWidth > MAX_LINE_WIDTH)
		LineWidth = MAX_LINE_WIDTH;
	
	// find the join type
	JointType JType;
	switch(CDRDATA_WORD(Out->JoinStyle))
	{
		case cdrfJOINSTYLE_SQUARE:	JType = MitreJoin;		break;
		case cdrfJOINSTYLE_ROUNDED:	JType = RoundJoin;		break;
		default:
		case cdrfJOINSTYLE_BEVEL:	JType = BevelledJoin;	break;
	}
	
	// set the cap style
	LineCapType CType;
	switch(Out->EndStyle)  // byte
	{
		case cdrfENDSTYLE_BUTT:		CType = LineCapButt;	break;
		case cdrfENDSTYLE_ROUNDED:	CType = LineCapRound;	break;
		default:
		case cdrfENDSTYLE_SQUARE:	CType = LineCapSquare;	break;

	}

	// set the dash pattern
/*	DashRec Dash;
	DashElement DashArray[cdrfMAX_DASH_ELEMENTS];
	if((ObjectFlagsV3 & cdrfOBJFLAGSV3_NODASH) == 0 && Out->NDashSegments > 0)		// byte
	{
		// set a dash pattern
		INT32 NSeg = CDRDATA_WORD(Out->NDashSegments);
		if(NSeg > cdrfMAX_DASH_ELEMENTS)
			NSeg = cdrfMAX_DASH_ELEMENTS;

		INT32 l;
		for(l = 0; l < NSeg; l++)
		{
			DashArray[l] = Out->DashSegments[l] * LineWidth;  // byte
		}

		Dash.Elements = NSeg;
		Dash.DashStart = 0;
		Dash.ElementData = DashArray;

		Dash.LineWidth = LineWidth;
		Dash.ScaleWithLineWidth = TRUE;
		Dash.DashID = -1;
	}
	else
	{
		// no dash pattern
		Dash = SD_SOLID;
	}
*/
	// set the attributes
	if(!SetLineWidth(LineWidth) || !SetLineColour(Col) || !SetJoinType(JType)
			|| !SetLineCap(CType)/* || !SetDashPattern(Dash)*/)
		return FALSE;

	// check for arrowheads
	if(CDRDATA_DWORD(Out->StartArrowReference) != 0 || CDRDATA_DWORD(Out->EndArrowReference) != 0)
	{
		// apply the attributes to the object
		// If not filled, then set the ignore bit on the fill attribute.
		if (ObjFilled == FALSE)
			CurrentAttrs[ATTR_FILLGEOMETRY].Ignore = TRUE;

		// Add attributes to the path, if they are different from the default...
		AttributeManager::ApplyBasedOnDefaults(pMadeNode, CurrentAttrs);

		// Enable the fill attribute again
		CurrentAttrs[ATTR_FILLGEOMETRY].Ignore = FALSE;

		// ensure that the attributes won't be applied again
		AttrsAlreadyApplied = TRUE;

		// apply arrow heads to the path
		AddArrowheadsToPath(CDRDATA_DWORD(Out->StartArrowReference), CDRDATA_DWORD(Out->EndArrowReference),
				&Col, LineWidth, CType, JType);
	}

	return TRUE;
}