void CChartCandlestickSerie::AddPoint(double XVal,
									  double Low,
									  double High,
									  double Open,
									  double Close)
{
	SChartCandlestickPoint NewPoint(XVal, Low, High, Open, Close);
	CChartSerieBase<SChartCandlestickPoint>::AddPoint(NewPoint);
}
Beispiel #2
0
BOOL ProcessPath::InsertQuantisedLineTo(DocCoord * pEnd, DocCoord * pStart)
{
	INT32 dx = pEnd->x - pStart->x;
	INT32 dy = pEnd->y - pStart->y;
	INT32 pdx = (dx<0)?(-dx):dx;
	INT32 pdy = (dy<0)?(-dy):dy;
	INT32 maxdist = (pdx<pdy)?pdy:pdx;
	INT32 points = (INT32)((((double)maxdist/ProcFlatness)) + 0.5);
	if (points<=1) return NewPoint(PT_LINETO, pEnd);
	if (points>10) points=10;
	DocCoord intermediate;
	INT32 n;
	for (n=1; n<=points; n++)
	{
		double d=((double)n/(double)points);
		intermediate.x=pStart->x + (INT32)(0.5+d*(double)dx);		
		intermediate.y=pStart->y + (INT32)(0.5+d*(double)dy);
		if (!NewPoint(PT_LINETO, &intermediate)) return FALSE;
	}
	return TRUE;
}
Beispiel #3
0
Octree	*
new_Octant(Octree *parentp, Octree **childpp, int bitv, int level)
{
    register Octree	*childp;
    fastf_t	delta = modl_radius / pow_Of_2( level );
    register float	*origin = parentp->o_points->c_point;
    /* Create child node, filling in parent's pointer.		*/
    if ( ! NewOctree( *childpp ) )
    {
	Malloc_Bomb(sizeof(Octree));
	fatal_error = TRUE;
	return	OCTREE_NULL;
    }
    /* Fill in fields in child node.				*/
    childp = *childpp;
    childp->o_bitv = bitv;
    childp->o_temp = ABSOLUTE_ZERO;   /* Unclaimed by temperature.	*/
    childp->o_triep = TRIE_NULL;	  /* Unclaimed by region.	*/
    childp->o_sibling = OCTREE_NULL;  /* End of sibling chain.	*/
    childp->o_child = OCTREE_NULL;	  /* No children yet.		*/

    /* Create list node for origin of leaf octant.			*/
    if ( ! NewPoint( childp->o_points ) )
    {
	Malloc_Bomb(sizeof(PtList));
	fatal_error = TRUE;
	return	OCTREE_NULL;
    }
    childp->o_points->c_next = PTLIST_NULL; /* End of pt. chain.	*/
    /* Compute origin relative to parent, based on bit vector.	*/
    if ( bitv & 1<<X )
	childp->o_points->c_point[X] = origin[X] + delta;
    else
	childp->o_points->c_point[X] = origin[X] - delta;
    if ( bitv & 1<<Y )
	childp->o_points->c_point[Y] = origin[Y] + delta;
    else
	childp->o_points->c_point[Y] = origin[Y] - delta;
    if ( bitv & 1<<Z )
	childp->o_points->c_point[Z] = origin[Z] + delta;
    else
	childp->o_points->c_point[Z] = origin[Z] - delta;
    return	childp;
}
void ExerimentSimple::DrawScatterPlot()
{
    for(int i=0;i<(int)Data.size();i++)
    {
        Point2D NewPoint(Data[i][0], Data[i][1]);
        NewPoint.color = makeVector4f(Data[i][0], Data[i][1], 0.5, 1);
        viewer->addPoint(NewPoint);
    }

    //Axes
    Point2D Origin(0, 0);
    Origin.color = makeVector4f(1,1,1,1);
    Origin.size = 10;
    const int idOrigin = viewer->addPoint(Origin);

    Point2D XOff(1.1, 0);
    XOff.color = makeVector4f(1,0,0,1);
    XOff.size = 10;
    const int idXOff = viewer->addPoint(XOff);

    Point2D YOff(0, 1.1);
    YOff.color = makeVector4f(0,1,0,1);
    YOff.size = 10;
    const int idYOff = viewer->addPoint(YOff);

    //X-Axis
    Line Axis;
    Axis.vertices[0] = idOrigin;
    Axis.vertices[1] = idXOff;
    Axis.color = makeVector4f(1,1,1,1);
    Axis.thickness = 3;
    viewer->addLine(Axis);

    //Y-Axis
    Axis.vertices[1] = idYOff;
    viewer->addLine(Axis);

    // display changes
    viewer->refresh();
}
Beispiel #5
0
int
append_PtList(fastf_t *pt, PtList *ptlist)
{
    for (; ptlist->c_next != PTLIST_NULL; ptlist = ptlist->c_next )
    {
	if ( SamePoint( ptlist->c_next->c_point, pt, F2D_EPSILON ) )
	{
	    /* Point already in list.		*/
	    return	1;
	}
    }
    if ( ! NewPoint( ptlist->c_next ) )
    {
	Malloc_Bomb(sizeof(PtList));
	fatal_error = TRUE;
	return	0;
    }
    ptlist = ptlist->c_next;
    VMOVE( ptlist->c_point, pt );
    ptlist->c_next = PTLIST_NULL;
    return	1;
}
Beispiel #6
0
void ProcessPathToTrapezoids::CloseFigure(void)
{
	// Find this subpath's edge list
	TrapEdgeList *pEdgeList = pTraps->GetLastTrapEdgeList();
	if (pEdgeList == NULL)
		return;

	// Find the first and last TrapEdges for this subpath. If either is NULL
	// or if they are the same, then we don't have enough trapezoids to bake
	// a cake, so we throw in the towel.
	TrapEdge *pFirstEdge = pEdgeList->GetTrapEdge(0);
	TrapEdge *pLastEdge	 = pEdgeList->GetLastTrapEdge();
	if (pFirstEdge == NULL || pLastEdge == NULL || pFirstEdge == pLastEdge)
		return;

	// Now, compare the edge points. If they are coincident, we must add a join
	// to complete the shape, but if they are not, we leave the path unclosed
	if (pFirstEdge->Centre == pLastEdge->Centre)
	{
		PointFollowsJoin = TRUE;
		NewPoint(PT_LINETO, NULL);
	}
}
void FSplineComponentVisualizer::OnAddKey()
{
	const FScopedTransaction Transaction(LOCTEXT("AddSplinePoint", "Add Spline Point"));
	USplineComponent* SplineComp = GetEditedSplineComponent();
	check(SplineComp != nullptr);
	check(LastKeyIndexSelected != INDEX_NONE);
	check(SelectedKeys.Num() > 0);
	check(SelectedKeys.Contains(LastKeyIndexSelected));
	check(SelectedTangentHandle == INDEX_NONE);
	check(SelectedTangentHandleType == ESelectedTangentHandle::None);

	SplineComp->Modify();
	if (AActor* Owner = SplineComp->GetOwner())
	{
		Owner->Modify();
	}

	FInterpCurveVector& SplineInfo = SplineComp->SplineInfo;
	FInterpCurveQuat& SplineRotInfo = SplineComp->SplineRotInfo;
	FInterpCurveVector& SplineScaleInfo = SplineComp->SplineScaleInfo;

	FInterpCurvePoint<FVector> NewPoint(0.0f, SplineComp->ComponentToWorld.InverseTransformPosition(SelectedSplinePosition), FVector::ZeroVector, FVector::ZeroVector, CIM_CurveAuto);
	FInterpCurvePoint<FQuat> NewRotPoint(0.0f, FQuat::Identity, FQuat::Identity, FQuat::Identity, CIM_CurveAuto);
	FInterpCurvePoint<FVector> NewScalePoint(0.0f, FVector(1.0f), FVector::ZeroVector, FVector::ZeroVector, CIM_CurveAuto);

	SplineInfo.Points.Insert(NewPoint, SelectedSegmentIndex + 1);
	SplineRotInfo.Points.Insert(NewRotPoint, SelectedSegmentIndex + 1);
	SplineScaleInfo.Points.Insert(NewScalePoint, SelectedSegmentIndex + 1);

	// Set selection to 'next' key
	ChangeSelectionState(SelectedSegmentIndex + 1, false);
	SelectedSegmentIndex = INDEX_NONE;

	NotifyComponentModified();

	CachedRotation = SplineComp->GetQuaternionAtSplinePoint(LastKeyIndexSelected, ESplineCoordinateSpace::World);
}
Beispiel #8
0
void Experiment1_1::DrawScatterPlot()
{
    max_Data = makeVector2f(Data[0][0], Data[0][1]);
    min_Data = makeVector2f(Data[0][0], Data[0][1]);
    for(int i=0;i<(int)Data.size();i++)
    {
        if(i>0)
        {
          if (Data[i][0] > max_Data [0])
          {
            max_Data[0]=Data[i][0];
          }
          if (Data[i][1] > max_Data [1])
          {
            max_Data[1]=Data[i][1];
          }
          if (Data[i][0] < min_Data [0])
          {
            min_Data[0]=Data[i][0];
          }
          if (Data[i][1] < min_Data [1])
          {
            min_Data[1]=Data[i][1];
          }

        }
    }
    DataColorRange = makeVector2f(max_Data[0]-min_Data[0], max_Data[1]-min_Data[1]);
    if (max_Data[0]<0)
        max_Data[0]=0;
    if (max_Data[1]<0)
        max_Data[1]=0;
    if (min_Data[0]>0)
        min_Data[0]=0;
    if (min_Data[1]>0)
        min_Data[1]=0;

    for(int i=0;i<(int)Data.size();i++)
    {
        Point2D NewPoint(Data[i][0], Data[i][1]);
        NewPoint.color = makeVector4f(Data[i][0]/DataColorRange[0], Data[i][1]/DataColorRange[1], 0.5 /*((float) i)/Data.size()*/, 1);
        viewer->addPoint(NewPoint);
    }
    //Axes
    Point2D Origin(0, 0);
    Origin.color = makeVector4f(1,1,1,1);
    Origin.size = 10;
    const int idOrigin = viewer->addPoint(Origin);

    Point2D XNeg(min_Data[0], 0);
    Point2D XPos(max_Data[0], 0);
    XNeg.color = makeVector4f(1,0,0,1);
    XPos.color = makeVector4f(1,0,0,1);
    XNeg.size = 10;
    XPos.size = 10;
    const int idXNeg = viewer->addPoint(XNeg);
    const int idXPos = viewer->addPoint(XPos);

    Point2D YNeg(0, min_Data[1]);
    Point2D YPos(0, max_Data[1]);
    YPos.color = makeVector4f(0,1,0,1);
    YNeg.color = makeVector4f(0,1,0,1);
    YPos.size = 10;
    YNeg.size = 10;
    const int idYPos = viewer->addPoint(YNeg);
    const int idYNeg = viewer->addPoint(YPos);

    //X-Axis
    Line Axis;
    Axis.vertices[0] = idXNeg;
    Axis.vertices[1] = idXPos;
    Axis.color = makeVector4f(1,1,1,1);
    Axis.thickness = 3;
    viewer->addLine(Axis);

    //Y-Axis
    Axis.vertices[0] = idYNeg;
    Axis.vertices[1] = idYPos;
    viewer->addLine(Axis);

    // display changes
    viewer->refresh();
}
Beispiel #9
0
Octree	*
add_Region_Octree(Octree *parentp, fastf_t *pt, Trie *triep, int temp, int level)
{
    Octree	*newp;
    /* Traverse to octant leaf node containing "pt".		*/
    if ( (newp = find_Octant( parentp, pt, &level )) == OCTREE_NULL )
    {
	bu_log( "find_Octant() returned NULL!\n" );
	return	OCTREE_NULL;
    }

    /* Decide where to put datum.					*/
    if ( newp->o_points->c_next == PTLIST_NULL )
    {
	/* Octant empty, so place region here.		*/
	newp->o_triep = triep;
	if ( ! NewPoint( newp->o_points->c_next ) )
	{
	    Malloc_Bomb(sizeof(PtList));
	    fatal_error = TRUE;
	    return	OCTREE_NULL;
	}
	VMOVE( newp->o_points->c_next->c_point, pt );
	newp->o_points->c_next->c_next = PTLIST_NULL;
	if ( temp != AMBIENT-1 )
	    newp->o_temp = temp;
	return	newp;
    }
    else	  /* Octant occupied.					*/
	if ( triep != newp->o_triep )
	{
	    /* Region collision, must subdivide octant.		*/
	    if ( ! subdivide_Octree(	newp, level ))
		return	OCTREE_NULL;
	    return	add_Region_Octree( newp, pt, triep, temp, level );
	}
	else
	    if ( temp != AMBIENT-1 )
	    {
		/* We are assigning a temperature.			*/
		if ( newp->o_temp < AMBIENT )
		{
		    /* Temperature not assigned yet.		*/
		    newp->o_temp = temp;
		    if ( ! append_PtList( pt, newp->o_points ) )
			return	OCTREE_NULL;
		}
		else
		    if ( Abs(newp->o_temp - temp) < ir_noise )
		    {
			/* Temperatures close enough.			*/
			if ( ! append_PtList( pt, newp->o_points ) )
			    return	OCTREE_NULL;
		    }
		    else
			if (	newp->o_points->c_next->c_next == PTLIST_NULL
				&&	SamePoint(	newp->o_points->c_next->c_point,
							pt,
							F2D_EPSILON
				    )
			    ) /* Only point in leaf node is this point.	*/
			    newp->o_temp = temp;
			else
			{
			    /* Temperature collision, must subdivide.	*/
			    if ( ! subdivide_Octree(	newp, level ) )
				return	OCTREE_NULL;
			    return	add_Region_Octree( newp, pt, triep, temp, level );
			}
	    }
	    else	/* Region pointers match, so append coordinate to list.	*/
		if ( ! append_PtList( pt, newp->o_points ) )
		    return	OCTREE_NULL;
    return	newp;
}
Beispiel #10
0
BOOL ProcessPath::FlattenCurve(	INT32 Px0,INT32 Py0,
								INT32 Px1,INT32 Py1,
								INT32 Px2,INT32 Py2,
								INT32 Px3,INT32 Py3, BOOL QuantiseAll)
{
	INT32 diff;

	INT32 dx0 = (Px1*3 - Px0*2 - Px3);
	if (dx0 < 0) dx0 = -dx0;
	//dx0 = dx0 < 0 ? -dx0 : dx0;

	INT32 dy0 = (Py1*3 - Py0*2 - Py3);
	if (dy0 < 0) dy0 = -dy0;
	//dy0 = dy0 < 0 ? -dy0 : dy0;
	
	// Get the line's distance from the curve
	if (dx0 >= dy0)
		diff = 3*dx0 + dy0;
	else
		diff = dx0 + 3*dy0;
		
	// Is the straight line close enough to the curve ?
	if (diff > ProcFlatness)
	{
		// Not close enough so split it into two and recurse for each half
		BOOL ok = FlattenSplit(Px0,Py0, Px1,Py1, Px2,Py2, Px3,Py3, QuantiseAll);
    	return ok;
    }
    
	INT32 dx1 = (Px2*3 - Px0 - Px3*2);
	if (dx1 < 0) dx1 = -dx1;
	//dx1 = dx1 < 0 ? -dx1 : dx1;

	INT32 dy1 = (Py2*3 - Py0 - Py3*2);
	if (dy1 < 0) dy1 = -dy1;
	//1 = dy1 < 0 ? -dy1 : dy1;
	
	// Get the line's distance from the curve
	if (dx1 >= dy1)
		diff = 3*dx1 + dy1;
	else
		diff = dx1 + 3*dy1;

	// Is the straight line close enough to the curve ?
	if (diff > ProcFlatness)
	{
		// Not close enough so split it into two and recurse for each half
		BOOL ok = FlattenSplit(Px0,Py0, Px1,Py1, Px2,Py2, Px3,Py3, QuantiseAll);
    	return ok;
    }

	DocCoord npoint;
	npoint.x = Px3;
	npoint.y = Py3;

	// Line is now close enough so call the virtual function
    if (!QuantiseAll)
    	return NewPoint(PT_LINETO, &npoint);
    else
	{
		DocCoord spoint;
		spoint.x = Px0;
		spoint.y = Py0;
    	return InsertQuantisedLineTo(&npoint,&spoint);
	}
}
Beispiel #11
0
BOOL ProcessPath::Process(const ProcessFlags& PFlags)
{

	// The idea here is that we create a quantised path. This means we
	// scan through the path descretizing curves and lines dependent
	// on the flatness value given.

    DocCoord* ICoords = ProcSource->GetCoordArray();
	PathVerb* IVerbs = ProcSource->GetVerbArray();

	INT32 numinsource = ProcSource->GetNumCoords();

    INT32 i=0;
    BOOL ok = TRUE;

	// scan through the input verbs
    while ((i<numinsource) && (ok))
    {
		switch (IVerbs[i] & ~PT_CLOSEFIGURE)
		{
			case PT_MOVETO:
				OpenElement(PT_MOVETO, i);
				ok = NewPoint(PT_MOVETO, &ICoords[i]);
				if (CloseElement(ok, PT_MOVETO, i))
					i=(numinsource-1);
				break;

			case PT_LINETO:
				{
					BOOL IsCloseFigure = ((IVerbs[i] & PT_CLOSEFIGURE) != 0);	// Remember if this is the closing element

					OpenElement(PT_LINETO, i);
					if (!PFlags.QuantiseAll)
					{
						if (!PFlags.QuantiseLines)
							ok = NewPoint(PT_LINETO, &ICoords[i]);
						else
						{
							DocCoord End = ICoords[i];
							for (double mu = 0.2; (mu<1.2) && ok; mu+=0.2 )
							{
								DocCoord dest;
								dest.x = (INT32)((1-mu)*ProcPreviousEl.x + mu*End.x);
								dest.y = (INT32)((1-mu)*ProcPreviousEl.y + mu*End.y);
								ok = NewPoint(PT_LINETO, &dest);
							}
						}
					}
					else
					{
						ok = InsertQuantisedLineTo(&ICoords[i], &ProcPreviousEl);
					}
					if (CloseElement(ok, PT_LINETO, i))
						i=(numinsource-1);
					else if (IsCloseFigure)		// If continuing, and this is the end of a closed figure
						CloseFigure();			// then close it off
				}
				break;

			case PT_BEZIERTO:
				{
					BOOL IsCloseFigure = ((IVerbs[i+2] & PT_CLOSEFIGURE) != 0);	// Remember if this is the closing element

					OpenElement(PT_BEZIERTO, i);
					if (!PFlags.FlattenCurves)
						ok = NewPoint(PT_BEZIERTO, &ICoords[i]);
					else
					{
						ok = FlattenCurve(ProcPreviousEl.x, ProcPreviousEl.y,
										  ICoords[i].x, ICoords[i].y,
										  ICoords[i+1].x, ICoords[i+1].y,
										  ICoords[i+2].x, ICoords[i+2].y, (PFlags.QuantiseAll) );
					}
					if (CloseElement(ok, PT_BEZIERTO, i))
						i=(numinsource-1);
					else
					{
						if (IsCloseFigure)		// If continuing, and this is the end of a closed figure
							CloseFigure();		// then close it off

                		i+=2;
					}
				}
				break;

			default: ERROR3("ProcessPath::Process() - unknown path verb!");

    	}
		ICoords = ProcSource->GetCoordArray();
		IVerbs = ProcSource->GetVerbArray();
		i++;
		ProcFirstPoint = FALSE;
		ProcPreviousEl = ICoords[i-1];
    }
	return ok;
}
Beispiel #12
0
INT32 ProcessPathDistance::Process(const ProcessFlags& PFlags, INT32 AlreadyProcessed)
{

	// The idea here is that we create a quantised path. This means we
	// scan through the path descretizing curves and lines dependent
	// on the flatness value given.

    DocCoord* ICoords = ProcSource->GetCoordArray();
	PathVerb* IVerbs = ProcSource->GetVerbArray();

	UINT32*     IPressure = NULL;
	if (ProcSource->HasWidth())
		IPressure = ProcSource->GetWidthArray();
	
	//if (IPressure == NULL)
	//	ERROR3("No pressure array");

	INT32 numinsource = ProcSource->GetNumCoords();

    INT32 i=AlreadyProcessed;
    BOOL ok = TRUE;
	if ( i > 0)
	{
		ProcFirstPoint = FALSE;
	}
	
	// scan through the input verbs
    while ((i < numinsource) && (ok) && (!Found))
    {
	//	if (IPressure != NULL)
	//		TRACEUSER( "Diccon", _T("PathProc Pressure =  %d\n"), IPressure[i]);
		switch (IVerbs[i] & ~PT_CLOSEFIGURE)
		{
			case PT_MOVETO:
				OpenElement(PT_MOVETO, i);
				if (IPressure != NULL)
					ok = NewPointA(PT_MOVETO, &ICoords[i], &IPressure[i]);
				else
					ok = NewPoint(PT_MOVETO, &ICoords[i]);

				if (CloseElement(ok, PT_MOVETO, i))
					i=(numinsource-1);
				break;

			case PT_LINETO:
				{
					BOOL IsCloseFigure = ((IVerbs[i] & PT_CLOSEFIGURE) != 0);	// Remember if this is the closing element

					OpenElement(PT_LINETO, i);
					if (!PFlags.QuantiseAll)
					{
						if (!PFlags.QuantiseLines)
							if (IPressure != NULL)
								ok = NewPointA(PT_LINETO, &ICoords[i], &IPressure[i]);
							else
								ok = NewPoint(PT_LINETO, &ICoords[i]);
						else
						{
							DocCoord End = ICoords[i];
							for (double mu = 0.2; (mu<1.2) && ok; mu+=0.2 )
							{
								DocCoord dest;
								dest.x = (INT32)((1-mu)*ProcPreviousEl.x + mu*End.x);
								dest.y = (INT32)((1-mu)*ProcPreviousEl.y + mu*End.y);
								ok = NewPoint(PT_LINETO, &dest);
							}
						}
					}
					else
					{
						ok = InsertQuantisedLineTo(&ICoords[i], &ProcPreviousEl);
					}
					if (CloseElement(ok, PT_LINETO, i))
						i=(numinsource-1);
					else if (IsCloseFigure)		// If continuing, and this is the end of a closed figure
						CloseFigure();			// then close it off
				}
				break;

			case PT_BEZIERTO:
				{
					BOOL IsCloseFigure = ((IVerbs[i+2] & PT_CLOSEFIGURE) != 0);	// Remember if this is the closing element

					OpenElement(PT_BEZIERTO, i);
					if (!PFlags.FlattenCurves)
						ok = NewPoint(PT_BEZIERTO, &ICoords[i]);
					else
					{
						ok = FlattenCurve(ProcPreviousEl.x, ProcPreviousEl.y,
										  ICoords[i].x, ICoords[i].y,
										  ICoords[i+1].x, ICoords[i+1].y,
										  ICoords[i+2].x, ICoords[i+2].y, (PFlags.QuantiseAll) );
					}
					if (CloseElement(ok, PT_BEZIERTO, i))
						i=(numinsource-1);
					else
					{
						if (IsCloseFigure)		// If continuing, and this is the end of a closed figure
							CloseFigure();		// then close it off

                		i+=2;
					}
				}
				break;

			default: ERROR3("ProcessPath::Process() - unknown path verb!");

    	}
		ICoords = ProcSource->GetCoordArray();
		IVerbs = ProcSource->GetVerbArray();
		i++;
		ProcFirstPoint = FALSE;
		ProcPreviousEl = ICoords[i-1];
    }

	// we are recording the point previous to the one we just found. 
	// i represents the next point, i-1 is the point we just found, so 
	// the one before that is i-2
	if (Found)
		m_LastFoundIndex = i -2;

	INT32 ReturnValue;
	// we have processed i-1 points
	if (ok)
		ReturnValue = i-1; 
	else
		ReturnValue = -1;

	return ok;
}