<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,21 +1,27 @@
 CPU History:
+- blockers for 1.1:
+	- graph not working @done
+		- finish graphing code changes
+	- floater window position
+	- divider width
+
 - bugs:
-	- 1. app blows away graph
-		- getting overwritten by the idle time &quot;clearing&quot; method
-		- problem: we are storing 128 history values, but our bar width only goes down to 2 px: the redraw doesn't perform as expected
-			- either fix the drawing code to only pull the last x*barwidth ones, or do something else.
-	- 1. a.
-		- multicore support:
+	- multicore support:
+		- migrate code changes to drawDeltas
+			- switch code back to delta by default
 		- test with @boredzo's mac pro
-	- 2. cmd-w doesn't close prefs window or about window: escape does
-		- no known way to fix?
-	- 3. floater doesn't remember last position
+	- let the user pick a divider width
+	- floater doesn't remember last position
 		- set a pref for window position, draw graph to that location when we make it.
+		- changing prefs snaps graph back to center of screen
 	- 4. make window snap to screen edges
 		- see: MGSnappingWindow
 	- 5. transparency for graphing window
 		- hook up prefs to window setting
 		- transparency of dock icon as well?
+	- 2. cmd-w doesn't close prefs window or about window: escape does
+		- no known way to fix?
+
 - a system to keep release notes synced and build a disk image with what I need?
 
 Mem -&gt; CPU conversion key:
@@ -106,3 +112,9 @@ Archive:
 		- diff CPU source against memory monitor: @done @project(future)
 			- any changes with data source being reset? shouldn't be&#8230; @done @project(future)
 		- what about removing the notifications in favor of straight method callbacks? first, what's the underlying problem: don't solve what doesn't need solving @done @project(future)
+	- 1. app blows away graph @done @project(CPU History)
+		- getting overwritten by the idle time &quot;clearing&quot; method @done @project(CPU History)
+		- problem: we are storing 128 history values, but our bar width only goes down to 2 px: the redraw doesn't perform as expected @done @project(CPU History)
+			- either fix the drawing code to only pull the last x*barwidth ones, or do something else. @done @project(CPU History)
+		- drawing code not performing as expected. @done @project(CPU History)
+	- 1. a. @done @project(CPU History)</diff>
      <filename>CPUHist.taskpaper</filename>
    </modified>
    <modified>
      <diff>@@ -37,8 +37,10 @@ typedef struct cpudata {
 - (CPUInfo *)initWithCapacity:(unsigned)numItems;
 - (void)refresh;
 - (unsigned)numCPUs;
-- (void)startIterate;
+- (void)startForwardIterate;
+- (void)startBackwardIterate;
 - (BOOL)getNext:(CPUDataPtr)ptr forCPU:(unsigned)cpu;
+- (BOOL)getPrev:(CPUDataPtr)ptr forCPU:(unsigned)cpu;
 - (void)getCurrent:(CPUDataPtr)ptr forCPU:(unsigned)cpu;
 - (void)getLast:(CPUDataPtr)ptr forCPU:(unsigned)cpu;
 - (int)getSize;</diff>
      <filename>CPUInfo.h</filename>
    </modified>
    <modified>
      <diff>@@ -39,7 +39,7 @@
 {
 	self = [super init];
 
-	unsigned i;
+	unsigned i, j;
 
 /* from Hosey's CPU Usage.app:
 	We could get the number of processors the same way that we get the CPU usage info, but that allocates memory. */
@@ -83,6 +83,17 @@
 		return (nil);
 	}
 	
+	for(i = 0U; i &lt; numCPUs; i++)
+	{
+		CPUDataPtr cpudata = allcpudata[i];
+		for (j = 0U; j &lt; numItems; j++)
+		{
+			cpudata[j].idle = 1.0;
+		}
+	}
+
+
+	
 	return (self);
 }
 
@@ -156,11 +167,15 @@
 }
 
 
-- (void)startIterate
+- (void)startForwardIterate
 {
 	outptr = inptr;
 }
 
+- (void)startBackwardIterate
+{
+	outptr = (inptr - 1 &lt; 0 ? size - 1 : inptr - 1);
+}
 
 - (BOOL)getNext:(CPUDataPtr)ptr forCPU:(unsigned)cpu
 {
@@ -174,6 +189,17 @@
 	return (TRUE);
 }
 
+- (BOOL)getPrev:(CPUDataPtr)ptr forCPU:(unsigned)cpu
+{
+	if (outptr == -1)
+		return (FALSE);
+	*ptr = allcpudata[cpu][outptr--];
+	if (outptr &lt; 0)
+		outptr = size - 1;
+	if (outptr == inptr)
+		outptr = -1;
+	return (TRUE);
+}
 
 - (void)getCurrent:(CPUDataPtr)ptr forCPU:(unsigned)cpu
 {</diff>
      <filename>CPUInfo.m</filename>
    </modified>
    <modified>
      <diff>@@ -66,6 +66,11 @@
 - (void)drawComplete
 // completely redraw graphImage, put graph into displayImage
 {	
+
+
+	#undef NSLOG_DEBUG
+
+
 	
 	#ifdef NSLOG_DEBUG
 	NSLog(@&quot;%s redrawing complete graph&quot;, _cmd);
@@ -77,7 +82,7 @@
 	float			height = ( GRAPH_SIZE - (GRAPH_SPACER * (numCPUs - 1) ) ) / numCPUs; // returns just GRAPH_SIZE on single-core machines.
 	
 	float			width = GRAPH_SIZE;
-	int				x = 0;
+	float			x = 0.0;
 	float			y = 0.0, ybottom = 0.0;
 	int barWidth = (int)[[preferences objectForKey:BAR_WIDTH_SIZE_KEY] floatValue];
 	
@@ -85,57 +90,61 @@
 	// draw the cpu usage graph
 	
 	
-	for (cpu = 0; cpu &lt; numCPUs; cpu++ ) {
-		[cpuInfo startIterate];
-		ybottom = cpu * height;
-		NSLog(@&quot;%s cpu %i: %f&quot;, _cmd, cpu, ybottom);
+	for (cpu = 0U; cpu &lt; numCPUs; cpu++ ) {
+		[cpuInfo startBackwardIterate];
+
+		// init the base (bottom) of this cpu's graph space.
+		float yBase = cpu * (height + GRAPH_SPACER);
+		ybottom = yBase;
 		
-		if (cpu != 0)
+		#ifdef NSLOG_DEBUG
+		NSLog(@&quot;%s cpu %i: drawing starts at %f px high\n\n&quot;, _cmd, cpu, ybottom);
+		#endif
+		
+		if (cpu != 0) // we need to draw the transparent spacer
 		{
-			ybottom += GRAPH_SPACER;
-			NSLog(@&quot;%s cpu %i: %f&quot;, _cmd, cpu, ybottom);
+			// continue;
 			[[NSColor colorWithCalibratedRed:0.0 green:0.0 blue:0.0 alpha:0.0] set];
 			NSRectFill (NSMakeRect(0, ybottom, width, GRAPH_SPACER));
-			y = ybottom;
-		}
-		else
-		{
-			[[NSColor purpleColor] set];
-			NSRectFill (NSMakeRect(0, ybottom, width, height));
 		}
 		
 		// set the idle background
-		/*
-			TODO these two lines are responsible for the redrawing erasure bug
-		*/
 		[[preferences objectForKey:IDLE_COLOR_KEY] set];
-		NSRectFill(NSMakeRect(0, ybottom, width, ybottom + height));
-		
-		for (x = 0; [cpuInfo getNext:&amp;cpudata forCPU:cpu]; x += barWidth) {
-			
+		NSRectFill(NSMakeRect(0, ybottom, width, height));
+		// loop through the previous CPU data and draw them.
+		for (x = width; x &gt; 0.0 &amp;&amp; [cpuInfo getPrev:&amp;cpudata forCPU:cpu]; x -= (float)barWidth) {
 			#ifdef NSLOG_DEBUG
-			NSLog(@&quot;CPU %d: User: %f, Sys: %f, Idle: %f&quot;, cpu, cpudata.user, cpudata.sys, cpudata.idle);
+			NSLog(@&quot;%s width left to draw: %.2f&quot;, _cmd, x);
+			NSLog(@&quot;CPU %d: User: %.4f, Sys: %.4f, Idle: %.4f&quot;, cpu, cpudata.user, cpudata.sys, cpudata.idle);
 			#endif
 			
-			y = ybottom + cpudata.sys * height;
+			ybottom = yBase;
+			y = cpudata.sys * height;
 			[[preferences objectForKey:SYS_COLOR_KEY] set];
-			NSRectFill (NSMakeRect(x, ybottom, x + barWidth, y));
-			ybottom = y;
-			
-			y += cpudata.nice * height;
-			[[preferences objectForKey:NICE_COLOR_KEY] set];
-			NSRectFill (NSMakeRect(x, ybottom, x + barWidth, y));
-			ybottom = y;
+			#ifdef NSLOG_DEBUG
+			NSLog(@&quot;%s system:\t\t(%.2f, %.2f) by (%.2f, %.2f)&quot;, _cmd, x - (float)barWidth, ybottom, (float)barWidth, y);
+			NSLog(@&quot;%s y = %.2f, ybottom = %.2f&quot;, _cmd, y, ybottom);
+			#endif
+			NSRectFill (NSMakeRect(x - (float)barWidth, ybottom, (float)barWidth, y));
+			ybottom += y;
 			
-			y += cpudata.user * height;
+			y = cpudata.user * height;
 			[[preferences objectForKey:USER_COLOR_KEY] set];
-			NSRectFill (NSMakeRect(x, ybottom, x + barWidth, y));
-			ybottom = y;
+			#ifdef NSLOG_DEBUG
+			NSLog(@&quot;%s user:\t\t(%.2f, %.2f) by (%.2f, %.2f)&quot;, _cmd, x - (float)barWidth, ybottom, (float)barWidth, y);
+			NSLog(@&quot;%s y = %.2f, ybottom = %.2f&quot;, _cmd, y, ybottom);
+			#endif
+			NSRectFill (NSMakeRect(x - (float)barWidth, ybottom, (float)barWidth, y));
+			ybottom += y;
 			
-			y += cpudata.idle * height;
+			y = cpudata.idle * height;
 			[[preferences objectForKey:IDLE_COLOR_KEY] set];
-			NSRectFill (NSMakeRect(x, ybottom, x + barWidth, y));
-			ybottom = y;
+			#ifdef NSLOG_DEBUG
+			NSLog(@&quot;%s idle:\t\t(%.2f, %.2f) by (%.2f, %.2f)&quot;, _cmd, x - (float)barWidth, ybottom, (float)barWidth, y);
+			NSLog(@&quot;%s y = %.2f, ybottom = %.2f&quot;, _cmd, y, ybottom);
+			#endif
+			NSRectFill (NSMakeRect(x - (float)barWidth, ybottom, (float)barWidth, y));
+			ybottom += y;
 		}
 	}
 	
@@ -203,13 +212,6 @@
 		[[preferences objectForKey:SYS_COLOR_KEY] set];
 		NSRectFill (NSMakeRect(width - barWidth, ybottom, width - barWidth, y));
 		ybottom = y;
-
-		y += cpudata.nice * height;
-		// y += cpudata.nice * height;
-		[[preferences objectForKey:NICE_COLOR_KEY] set];
-		NSRectFill (NSMakeRect(width - barWidth, ybottom, width - barWidth, y));
-		ybottom = y;
-		
 		
 		// y = vmdata.wired * GRAPH_SIZE;
 		y += cpudata.user * height;
@@ -217,7 +219,6 @@
 		NSRectFill (NSMakeRect(width - barWidth, ybottom, width - barWidth, y));
 		ybottom = y;
 		
-		// free data here
 		y += cpudata.idle * height;
 		[[preferences objectForKey:IDLE_COLOR_KEY] set];
 		// [[NSColor blueColor] set];
@@ -247,9 +248,8 @@
 - (void)refreshGraph
 // get a new sample and refresh the graph
 {
-	// [memInfo refresh];
 	[cpuInfo refresh];
-	[self drawDelta];
+	[self drawComplete];
 	[self setApplicationIcon];
 	
 	if ([[preferences objectForKey:SHOW_GRAPH_WINDOW_KEY] boolValue]) {
@@ -356,7 +356,6 @@
 	[NSApp setApplicationIconImage:[NSImage imageNamed:@&quot;CPUHistory.icns&quot;]];
 	
 	preferences = [[Preferences alloc] init];
-	// memInfo = [[MemInfo alloc] initWithCapacity:GRAPH_SIZE];
 	cpuInfo = [[CPUInfo alloc] initWithCapacity:GRAPH_SIZE];
 	if (nil == cpuInfo) //then we need to bomb out. We can't do anything else.
 	{
@@ -395,11 +394,7 @@
 	[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showHideWindow) name:PREFERENCES_CHANGED object:nil];
 	[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateGraph) name:PREFERENCES_CHANGED object:nil];
 	[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setTimer) name:PREFERENCES_CHANGED object:nil];
-
-/*	if ([self systemVersion] &lt; 0x1010 &amp;&amp; [self isLoginItem])
-		[NSTimer scheduledTimerWithTimeInterval:30 target:self selector:@selector(setTimer) userInfo:nil repeats:NO];
-	else
-*/ // We can stop supporting 10.1 now. Welcome to 2003, people.
+	
 	[self setTimer];
 }
 </diff>
      <filename>MainController.m</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>ad6c1381d256313d4c18f995878e5ad9980937b7</id>
    </parent>
  </parents>
  <author>
    <name>Christopher Bowns</name>
    <email>christopher@cbowns.com</email>
  </author>
  <url>http://github.com/cbowns/cpu-history/commit/430b4267a2f721bca4b5bf7cb487cebbd8616634</url>
  <id>430b4267a2f721bca4b5bf7cb487cebbd8616634</id>
  <committed-date>2008-04-20T08:09:08-07:00</committed-date>
  <authored-date>2008-04-20T08:09:08-07:00</authored-date>
  <message>preliminary multicore support. forward and backward iterating methods for traversing past history data.</message>
  <tree>5a992704e0ce8d18169dcf9fb53a1edf3fc64e6a</tree>
  <committer>
    <name>Christopher Bowns</name>
    <email>christopher@cbowns.com</email>
  </committer>
</commit>
