next up previous contents
Next: Single sphere demonstration Up: Main menu in Objective Previous: Main menu in Objective   Contents

Simple replacement of Turbo C GEOM

Figure: Objective C master panel designed as a simple replacement for the MS-DOS interface. Of course, the resemblance is only approximate.
\begin{figure}\begin{picture}(400,400)(60,0)
\epsffile{fig14.eps}\end{picture}\end{figure}

/* - - - - - - - - - - - - -  G E O M  - - - - - - - - - - - - - - - - - */

- readEulerAngles:sender
{
  a0[0]=180.0*[[euRot cellAt:0:0] doubleValue];
  a0[1]=180.0*[[euRot cellAt:1:0] doubleValue];
  a0[2]=180.0*[[euRot cellAt:2:0] doubleValue];
return self;
}

- readAngleAxis:(double *)a:(double *)aa
{
  a[0]=[[cosRot cellAt:0:0] doubleValue];
  a[1]=[[cosRot cellAt:1:0] doubleValue];
  a[2]=[[cosRot cellAt:2:0] doubleValue];
  *aa=[angRot doubleValue];
  if (a[0]==0.0&&a[1]==0.0&a[2]==0.0) a[0]=a[1]=a[2]=0.886;
return self;
}

- readParameters:sender
{int i, j; double o[3][3], a[3];
  if (strcmp([[sender selectedCell] title],"sphere 1")==0) i=0;
  if (strcmp([[sender selectedCell] title],"sphere 2")==0) i=1;
  if (strcmp([[sender selectedCell] title],"sphere 3")==0) i=2;
  for (j=0; j<3; j++) [[rightCenter cellAt:j:0] setDoubleValue:u[i][j]];
  [rightRadius setDoubleValue:u[i][3]];
  for (j=0; j<3; j++) [[rightEuler cellAt:j:0] setDoubleValue:u[i][j+4]];
spheu(o,&u[i][4]);
sphdc(a,o);
  [[rightAngles cellAt:0:0] setDoubleValue:a[0]]; 
  [[rightAngles cellAt:1:0] setDoubleValue:a[1]]; 
  [[rightAngles cellAt:2:0] setDoubleValue:a[2]]; 
  [[rightAngles cellAt:3:0] setDoubleValue:sphar(o)]; 
return self;
}

- rotateMolecule:sender
{
  m0[0]=[[cosRot cellAt:0:0] doubleValue];
  m0[1]=[[cosRot cellAt:1:0] doubleValue];
  m0[2]=[[cosRot cellAt:2:0] doubleValue];
  m0[3]=360.0*[angRot  doubleValue];
  if (m0[0]==0.0&&m0[1]==0.0&m0[2]==0.0) m0[0]=m0[1]=m0[2]=0.886;
  sphax(mrot,m0[3],m0[0],m0[1],m0[2]);

return self;
}

- setParameters:sender
{int i, j; double o[3][3], a[3];
  if (strcmp([sphereMenu title],"sphere 1")==0) i=0;
  if (strcmp([sphereMenu title],"sphere 2")==0) i=1;
  if (strcmp([sphereMenu title],"sphere 3")==0) i=2;
  for (j=0; j<3; j++) u[i][j]=[[rightCenter cellAt:j:0] doubleValue];
  u[i][3]=[rightRadius doubleValue];
  for (j=0; j<3; j++) u[i][j+4]=[[rightEuler cellAt:j:0] doubleValue];
spheu(o,&u[i][4]);
sphdc(a,o);
  [[rightAngles cellAt:0:0] setDoubleValue:a[0]]; 
  [[rightAngles cellAt:1:0] setDoubleValue:a[1]]; 
  [[rightAngles cellAt:2:0] setDoubleValue:a[2]]; 
  [[rightAngles cellAt:3:0] setDoubleValue:sphar(o)]; 
return self;
}

- setLighting:sender
{
double a[3], aa;
  [self readAngleAxis:a:&aa];
  sphax(uu,aa,a[0],a[1],a[2]);
  [[leftAngles cellAt:0:0] setDoubleValue:a[0]]; 
  [[leftAngles cellAt:1:0] setDoubleValue:a[1]]; 
  [[leftAngles cellAt:2:0] setDoubleValue:a[2]]; 
  [[leftAngles cellAt:3:0] setDoubleValue:sphar(uu)]; 
return self;
}

- setRotation:sender
{
  switch ([sender selectedRow]) {
    case 0: [angRot setDoubleValue:90.0/360.0];
            [[cosRot cellAt:0:0] setDoubleValue:0.0];
            [[cosRot cellAt:1:0] setDoubleValue:1.0];
            [[cosRot cellAt:2:0] setDoubleValue:0.0];
            break;
    case 1: [angRot setDoubleValue:90.0/360.0];
            [[cosRot cellAt:0:0] setDoubleValue:0.0];
            [[cosRot cellAt:1:0] setDoubleValue:0.0];
            [[cosRot cellAt:2:0] setDoubleValue:1.0];
            break;
    case 2: [angRot setDoubleValue:90.0/360.0];
            [[cosRot cellAt:0:0] setDoubleValue:1.0];
            [[cosRot cellAt:1:0] setDoubleValue:0.0];
            [[cosRot cellAt:2:0] setDoubleValue:0.0];
            break;
    case 3: [angRot setDoubleValue:60.0/360.0];
            [[cosRot cellAt:0:0] setDoubleValue:0.3];
            [[cosRot cellAt:1:0] setDoubleValue:0.3];
            [[cosRot cellAt:2:0] setDoubleValue:0.3];
            break;
    default:break;}
return self;
}

- showSphere:sender
{
  drawView=0;
  drawSphere=YES;
  [self display];
  drawSphere=NO;
        needsClearing = YES;
return self;
}

- showAxSphere:sender
{
  drawView=5;
  drawAxSphere=YES;
  [self display];
  drawAxSphere=NO;
        needsClearing = YES;
return self;
}

- showEuSphere:sender
{
  drawView=5;
  drawEuSphere=YES;
  [self display];
  drawEuSphere=NO;
        needsClearing = YES;
return self;
}

- showShadows:sender
{
  drawView=0;
  drawShadows=YES;
  [self display];
  drawShadows=NO;
        needsClearing = YES;
return self;
}

- prepSpiral:sender 
{
  pushMe=spImButton;
  [spImButton setTitle:"SPIRAL"];
  if ([orientButton state]) [euPanel orderFront:self];
    [gridPanel performClose:self];
    [liPanel performClose:self];
    [spPanel performClose:self];
  if ([paramButton state]) [spPanel orderFront:self];
return self;
}

- prepGrid:sender 
{
  pushMe=spImButton;
  [spImButton setTitle:"GRID"];
  if ([orientButton state]) [euPanel orderFront:self];
    [gridPanel performClose:self];
    [liPanel performClose:self];
    [spPanel performClose:self];
  if ([paramButton state]) [gridPanel orderFront:self];
return self;
}

- prepLissa:sender 
{
  pushMe=spImButton;
  [spImButton setTitle:"LISSAJOUS"];
  if ([orientButton state]) [euPanel orderFront:self];
    [gridPanel performClose:self];
    [liPanel performClose:self];
    [spPanel performClose:self];
  if ([paramButton state]) [liPanel orderFront:self];
return self;
}

- showUnisphere:sender
{
  drawUnisphere=YES;
  [self display];
  drawUnisphere=NO;
        needsClearing = YES;
return self;
}

- showDisphere:sender
{
int i;
double o[3][3], a[3], aa;
  if (strcmp([[rotateDimer selectedCell] title],"forward")==0) {
     [self readAngleAxis:a:&aa];
     sphax(o,aa,a[0],a[1],a[2]);

     for (i=0; i<3; i++) a[i]=[[leftCenter cellAt:i:0] doubleValue];
     sphmv(a,o,a);
     for (i=0; i<3; i++) [[leftCenter cellAt:i:0] setDoubleValue:a[i]];

     for (i=0; i<3; i++) a[i]=[[rightCenter cellAt:i:0] doubleValue];
     sphmv(a,o,a);
     for (i=0; i<3; i++) [[rightCenter cellAt:i:0] setDoubleValue:a[i]];
     }
   if (strcmp([[rotateDimer selectedCell] title],"backward")==0) {
     [self readAngleAxis:a:&aa];
     sphax(o,-aa,a[0],a[1],a[2]);

     for (i=0; i<3; i++) a[i]=[[leftCenter cellAt:i:0] doubleValue];
     sphmv(a,o,a);
     for (i=0; i<3; i++) [[leftCenter cellAt:i:0] setDoubleValue:a[i]];

     for (i=0; i<3; i++) a[i]=[[rightCenter cellAt:i:0] doubleValue];
     sphmv(a,o,a);
     for (i=0; i<3; i++) [[rightCenter cellAt:i:0] setDoubleValue:a[i]];
     }
 drawDisphere=YES;
  [self display];
  drawDisphere=NO;
        needsClearing = YES;
return self;
}

- printSphere:sender
{
  drawView=0;
  drawSphere=YES;
  [self printPSCode:self];
  drawSphere=NO;
        needsClearing = YES;

return self;
}

- printUnisphere:sender
{
  drawUnisphere=YES;
  [self printPSCode:self];
  drawUnisphere=NO;
        needsClearing = YES;
return self;
}

- printSpIm:sender
{
  sslen=[[spiralData cellAt:1:0] intValue];
  sspch=[[spiralData cellAt:0:0] intValue];
  drawUnisphere=YES;
  [self printPSCode:self];
  drawUnisphere=NO;
        needsClearing = YES;

return self;
}

- printDisphere:sender
{
  drawDisphere=YES;
  [self printPSCode:self];
  drawDisphere=NO;
        needsClearing = YES;

return self;
}

- rotateDimerB:sender
{
  [dimerButton setTitle:"Backward"];
return self;
}

- rotateDimerF:sender
{
  [dimerButton setTitle:"Forward"];
return self;
}

- rotateDimerN:sender
{
  [dimerButton setTitle:"Dimer"];
return self;
}

- pushIt:sender
{
  [pushMe performClick:self];
return self;
}



Pedro Hernandez 2004-05-13