mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
Voronoi diagram on chart
.. The diagram now displays on a chart, but there are a few issues. Will work through them as more testing done.
This commit is contained in:
@@ -8,9 +8,21 @@
|
||||
Voronoi::Voronoi()
|
||||
{
|
||||
// old controls essentially in main.c
|
||||
triangulate = 0;
|
||||
plot = 0;
|
||||
debug = 0;
|
||||
//
|
||||
// the original source was written in such a way that you could
|
||||
// update the "plotting functions" (line, circle etc) with your
|
||||
// own code to implement a plot.
|
||||
//
|
||||
// we have adapted the "line" function to record lines in the
|
||||
// output vector, so we can draw them on a plot
|
||||
//
|
||||
// testing has suggested that these kinds of diagrams only work
|
||||
// well when there are lots of cells ie, running kmeans with
|
||||
// 30 or even 100 clusters.
|
||||
//
|
||||
triangulate = 0; // tesselate (we don't support this)
|
||||
plot = 1; // call "plotting functions" - we use this
|
||||
debug = 0; // set to 1 to get lots of debug
|
||||
|
||||
// malloc lists are maintained and zapped in constructors
|
||||
freeinit(&sfl, sizeof(Site));
|
||||
@@ -98,6 +110,7 @@ Voronoi::run(QRectF /* boundingRect */)
|
||||
|
||||
// was done in main.c previously
|
||||
geominit();
|
||||
plotinit();
|
||||
|
||||
// now into the original sources
|
||||
Site *newsite, * bot, * top, * temp, * p, * v ;
|
||||
@@ -755,11 +768,13 @@ Voronoi::myalloc(unsigned n)
|
||||
void
|
||||
Voronoi::openpl(void)
|
||||
{
|
||||
output.clear();
|
||||
}
|
||||
|
||||
void
|
||||
Voronoi::line(float ax, float ay, float bx, float by)
|
||||
{
|
||||
output << QLineF(QPointF(ax,ay), QPointF(bx,by));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <QList>
|
||||
#include <QRectF>
|
||||
#include <QPointF>
|
||||
#include <QLineF>
|
||||
|
||||
#ifndef __VDEFS_H
|
||||
#define __VDEFS_H 1
|
||||
@@ -76,6 +77,9 @@ class Voronoi {
|
||||
void addSite(QPointF point);
|
||||
void run(QRectF boundingRect);
|
||||
|
||||
// the output is a vector of lines to draw
|
||||
QList<QLineF> &lines() { return output; }
|
||||
|
||||
private:
|
||||
|
||||
// original global variables
|
||||
@@ -99,6 +103,7 @@ class Voronoi {
|
||||
// refactoring to Qt containers
|
||||
QList<void *> malloclist; // keep tabs on all the malloc'ed memory
|
||||
QList<Site*> sites;
|
||||
QList<QLineF> output;
|
||||
|
||||
/*** implicit parameters: nsites, sqrt_nsites, xmin, xmax, ymin, ymax,
|
||||
: deltax, deltay (can all be estimates).
|
||||
|
||||
Reference in New Issue
Block a user