624Compiling VTK from Source on OSX

Getting the VTK ("Visualization Tool Kit") on Mac OSX running does not seems to be for the faint-of-heart.

I will follow the "Installing VTK on Mac OS X" from macresearch.org, as it was written in 2007, I'll highlight the differences to a current (August 2010, OSX 10.6) Installation.

CMake CMake can be installed with the following command macports sudo port install cmake

VTK - 1st Try Wondering if you can install VTK also with MacPorts? Wonder not longer, you can't.

VTK - 2nd Try Ok, sometimes following a tutorial is good. Obviously replace export MACOSX_DEPLOYMENT_TARGET=10.4u with your current OSX version (mine is now: 10.6)

614ControlP5, PeasyCam and HUD in Processing

A slight development of an ControlP5 example. I needed to have the controls over the PeasyCam, wasn't too hard to achieve. Nice one, Processing.

Here's the applet.

/**
 * ControlP5 with PeasyCam support. 
 * Tested with Processing 1.2.1, PeasyCam 0.8.3 and ControlP5 0.5.0
 *
 * original by
 * by jeffg 2009
 * http://processing.org/discourse/yabb2/YaBB.pl?num=1234988194/30#30
 *
 * modified by trembl 2010
 */

import peasy.*;
import controlP5.*;
import processing.opengl.*;

PeasyCam cam;
ControlP5 controlP5;
PMatrix3D currCameraMatrix;
PGraphics3D g3; 

int buttonValue = 1;

int myColor = color(255,0,0);
Slider r,gr,b;
void setup() {
  size(400,400,OPENGL);
  g3 = (PGraphics3D)g;
  cam = new PeasyCam(this, 100);
  cam.setMinimumDistance(-100);
  cam.setMaximumDistance(200);

  controlP5 = new ControlP5(this);
  //controlP5.addButton("button",10,10,10,80,20).setId(1);
  //controlP5.addButton("buttonValue",4,10,40,80,20).setId(2);

  r = controlP5.addSlider("redSlider",0,255,128,10,10,200,20);
  r.setColorActive(color(128,0,0));
  r.setColorBackground( color(127,100) );
  r.setColorForeground(color(255,0,0));
  r.setColorLabel(color(0,255,255,127));
  r.setColorValue(color(0,255,255,127));
  r.setLabel("");
  r.setLabelVisible(true);

  gr = controlP5.addSlider("greenSlider",0,255,128,10,40,200,20);
  gr.setColorActive(color(0,128,0));
  gr.setColorBackground( color(127,100) );
  gr.setColorForeground(color(0,255,0));
  gr.setColorLabel(color(0,255,255,127));
  gr.setColorValue(color(0,255,255,127));
  gr.setLabel("");
  gr.setLabelVisible(true);

  b = controlP5.addSlider("blueSlider",0,255,128,10,70,200,20);
  b.setColorActive(color(0,0,128));
  b.setColorBackground( color(127,100) );
  b.setColorForeground(color(0,0,128));
  b.setColorLabel(color(0,255,255,127));
  b.setColorValue(color(0,255,255,127));
  b.setLabel("");
  b.setLabelVisible(true);

  controlP5.setAutoDraw(false);
}
void draw() {

  background(0);
  fill(myColor);
  box(30);
  pushMatrix();
  translate(0,0,20);
  fill(0,0,255);
  box(5);
  popMatrix();

  cam.beginHUD();
  gui();
  cam.endHUD();

  cam.setMouseControlled(true);
  if(r.isInside() || gr.isInside() || b.isInside() ) {
    cam.setMouseControlled(false);
  } 
}

void gui() {
  currCameraMatrix = new PMatrix3D(g3.camera);
  camera();
  controlP5.draw();
  g3.camera = currCameraMatrix;
}

void redSlider(float v) {
  myColor = color( v, green(myColor), blue(myColor) );
  r.setColorActive(color(v,0,0));
}

void greenSlider(float v) {
  myColor = color(red(myColor), v, blue(myColor) );
  gr.setColorActive(color(0,v,0));
}

void blueSlider(float v) {
  myColor = color(red(myColor), green(myColor), v );
  b.setColorActive(color(0,0,v));
}

612Installing TextMate Bundles via Subversion

Instruction from the TextMate site, this is the minimal info for installing TextMate Bundles

mkdir -p /Library/Application\ Support/TextMate/Bundles cd /Library/Application\ Support/TextMate/Bundles svn co http://svn.textmate.org/trunk/Bundles/Haskell.tmbundle

Update all bundles cd /Library/Application\ Support/TextMate/Bundles svn up *.tmbundle

609Hide/Show Files in the Mac OSX GUI

Hiding files and folders from the Finder:

chflags hidden filename

And show them again:

chflags nohidden filename

608jQuery slideToggle flicker

I was running into a tiny, but annoying problem when using jQuery's slideToggle. When called, the hidden container would briefly become visible, then hide, and the nicely animate in.

SOLUTION: Turns out jQuery does not play nicely with tables. Instead using a table as a container, I wrapped the table into a <div> and applied the slideToggle to that. Works nicely.

606Safari 4 – Debug and Develop

The Developer Menu is straight-forward. Go to the Safari Preferences / Advanced and enable the menu.

The Debug Menu must be activated in the com.apple.Safari.plist. Either by issuing the following command: defaults write com.apple.Safari IncludeInternalDebugMenu 1

Or by opening the plist with the Property List Editor Application and adding a new 'IncludeInternalDebugMenu' node, with a boolean value set to 1. Same thing, different means.

Don't forget to restart Safari to see the changes.

594Delaying Methods. And cancelling the delaying of methods

Delaying a method should be by now fairly clear:

[self performSelector:@selector(myMethod) withObject:nil afterDelay:3];

But what, if you need to cancel the delayed perform request? That's the way to do it:

[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(myMethod) object:nil];

'cancelPreviousPerformRequestsWithTarget' seems to be the current leader in the 'Longest Objective C Method Name Competition" with 39 characters, not bad.

Let me know, if you find any more contenders...

591Fonts on the iPhone

I never seen to be able to remember the fonts available on the iPhone. Here's the code to print out all font families and font styles.

for (NSString *familyName in [UIFont familyNames]) {
    NSLog(@"%@, %@", familyName, [UIFont fontNamesForFamilyName:familyName]);
}

And here is the current result:

2010-05-17 17:38:05.931 fonts[20843:207] AppleGothic, (
    AppleGothic
)
2010-05-17 17:38:05.932 fonts[20843:207] Hiragino Kaku Gothic ProN, (
    "HiraKakuProN-W6",
    "HiraKakuProN-W3"
)
2010-05-17 17:38:05.932 fonts[20843:207] Arial Unicode MS, (
    ArialUnicodeMS
)
2010-05-17 17:38:05.932 fonts[20843:207] Heiti K, (
    "STHeitiK-Medium",
    "STHeitiK-Light"
)
2010-05-17 17:38:05.932 fonts[20843:207] DB LCD Temp, (
    DBLCDTempBlack
)
2010-05-17 17:38:05.932 fonts[20843:207] Helvetica, (
    "Helvetica-Oblique",
    "Helvetica-BoldOblique",
    Helvetica,
    "Helvetica-Bold"
)
2010-05-17 17:38:05.932 fonts[20843:207] Marker Felt, (
    "MarkerFelt-Thin"
)
2010-05-17 17:38:05.933 fonts[20843:207] Times New Roman, (
    TimesNewRomanPSMT,
    "TimesNewRomanPS-BoldMT",
    "TimesNewRomanPS-BoldItalicMT",
    "TimesNewRomanPS-ItalicMT"
)
2010-05-17 17:38:05.933 fonts[20843:207] Verdana, (
    "Verdana-Bold",
    "Verdana-BoldItalic",
    Verdana,
    "Verdana-Italic"
)
2010-05-17 17:38:05.933 fonts[20843:207] Georgia, (
    "Georgia-Bold",
    Georgia,
    "Georgia-BoldItalic",
    "Georgia-Italic"
)
2010-05-17 17:38:05.933 fonts[20843:207] Arial Rounded MT Bold, (
    ArialRoundedMTBold
)
2010-05-17 17:38:05.933 fonts[20843:207] Trebuchet MS, (
    "TrebuchetMS-Italic",
    TrebuchetMS,
    "Trebuchet-BoldItalic",
    "TrebuchetMS-Bold"
)
2010-05-17 17:38:05.933 fonts[20843:207] Heiti TC, (
    "STHeitiTC-Light",
    "STHeitiTC-Medium"
)
2010-05-17 17:38:05.933 fonts[20843:207] Geeza Pro, (
    "GeezaPro-Bold",
    GeezaPro
)
2010-05-17 17:38:05.934 fonts[20843:207] Courier, (
    Courier,
    "Courier-BoldOblique",
    "Courier-Oblique",
    "Courier-Bold"
)
2010-05-17 17:38:05.934 fonts[20843:207] Arial, (
    ArialMT,
    "Arial-BoldMT",
    "Arial-BoldItalicMT",
    "Arial-ItalicMT"
)
2010-05-17 17:38:05.934 fonts[20843:207] Heiti J, (
    "STHeitiJ-Medium",
    "STHeitiJ-Light"
)
2010-05-17 17:38:05.934 fonts[20843:207] Arial Hebrew, (
    ArialHebrew,
    "ArialHebrew-Bold"
)
2010-05-17 17:38:05.934 fonts[20843:207] Courier New, (
    "CourierNewPS-BoldMT",
    "CourierNewPS-ItalicMT",
    "CourierNewPS-BoldItalicMT",
    CourierNewPSMT
)
2010-05-17 17:38:05.934 fonts[20843:207] Zapfino, (
    Zapfino
)
2010-05-17 17:38:05.934 fonts[20843:207] American Typewriter, (
    AmericanTypewriter,
    "AmericanTypewriter-Bold"
)
2010-05-17 17:38:05.935 fonts[20843:207] Heiti SC, (
    "STHeitiSC-Medium",
    "STHeitiSC-Light"
)
2010-05-17 17:38:05.935 fonts[20843:207] Helvetica Neue, (
    HelveticaNeue,
    "HelveticaNeue-Bold"
)
2010-05-17 17:38:05.935 fonts[20843:207] Thonburi, (
    "Thonburi-Bold",
    Thonburi
)

590Adding an UIAlertView

Unlike other UIViews, UIAlertView does not need to be added to another view via addSubView. [myAlertView show] takes care of that.

Trivial, maybe. But I wasn't aware of it.

583UIAlertViews additional Buttons

UIAlertView *alert = [[UIAlertView alloc]
     initWithTitle:@"Hello"
     message:@"Do you really want to?"
     delegate:self
     cancelButtonTitle:@"Cancel" 
     otherButtonTitles:@"OK", nil];

The intuively unobvious thing is, that otherButtonTitles requires a nil-terminated, comma-seperated list(?) of NSStrings.

Although you can add (any number?) of additional buttons, it gets silly after about 3.

Another thing to note is that in the case of two buttons, they get displayed side by side, whereas one button or more than two are shown vertically stacked.