~ubuntu-branches/ubuntu/utopic/mricron/utopic

« back to all changes in this revision

Viewing changes to reorient.pas

  • Committer: Bazaar Package Importer
  • Author(s): Michael Hanke
  • Date: 2010-07-29 22:07:43 UTC
  • Revision ID: james.westby@ubuntu.com-20100729220743-q621ts2zj806gu0n
Tags: upstream-0.20100725.1~dfsg.1
ImportĀ upstreamĀ versionĀ 0.20100725.1~dfsg.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
unit reorient;
 
2
 
 
3
interface
 
4
 
 
5
uses
 
6
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
 
7
  StdCtrls, RXSpin,nifti_hdr,graphicsMathLibrary, ExtCtrls;
 
8
 
 
9
type
 
10
  TReorientForm = class(TForm)
 
11
    ZEdit: TRxSpinEdit;
 
12
    YEdit: TRxSpinEdit;
 
13
    XEdit: TRxSpinEdit;
 
14
    ReorientTimer: TTimer;
 
15
    PitchEdit: TRxSpinEdit;
 
16
    RollEdit: TRxSpinEdit;
 
17
    YawEdit: TRxSpinEdit;
 
18
    Label1: TLabel;
 
19
    Label2: TLabel;
 
20
    Label3: TLabel;
 
21
    Label4: TLabel;
 
22
    Label5: TLabel;
 
23
    Label6: TLabel;
 
24
    Xlabel: TLabel;
 
25
    YLabel: TLabel;
 
26
    ZLabel: TLabel;
 
27
    procedure ReorientTimerTimer(Sender: TObject);
 
28
    procedure EditChange(Sender: TObject);
 
29
  private
 
30
    { Private declarations }
 
31
  public
 
32
    procedure ApplyTransform ( var lHdr: TMRIcroHdr);
 
33
 
 
34
    { Public declarations }
 
35
  end;
 
36
 
 
37
var
 
38
  ReorientForm: TReorientForm;
 
39
 
 
40
implementation
 
41
 
 
42
uses nifti_img_view,nifti_img, nifti_hdr_view;
 
43
 
 
44
{$R *.DFM}
 
45
 
 
46
procedure TReorientForm.ApplyTransform ( var lHdr: TMRIcroHdr);
 
47
var
 
48
 lM,lRot: TMatrix;
 
49
begin
 
50
  //exit;
 
51
  if (XEdit.value = 0) and (YEdit.value = 0) and (ZEdit.value = 0)
 
52
  and (PitchEdit.value = 0) and  (YawEdit.value = 0)  and  (RollEdit.value = 0) then exit;
 
53
     lRot := Matrix3D (1,0,0,XEdit.value,
 
54
                         0,1,0,YEdit.value,
 
55
                         0,0,1,ZEdit.value,
 
56
                         0,0,0,1);
 
57
     lM := Matrix3D (
 
58
  lHdr.NIFTIhdr.srow_x[0],lHdr.NIFTIhdr.srow_x[1],lHdr.NIFTIhdr.srow_x[2],lHdr.NIFTIhdr.srow_x[3],      // 3D "graphics" matrix
 
59
  lHdr.NIFTIhdr.srow_y[0],lHdr.NIFTIhdr.srow_y[1],lHdr.NIFTIhdr.srow_y[2],lHdr.NIFTIhdr.srow_y[3],      // 3D "graphics" matrix
 
60
  lHdr.NIFTIhdr.srow_z[0],lHdr.NIFTIhdr.srow_z[1],lHdr.NIFTIhdr.srow_z[2],lHdr.NIFTIhdr.srow_z[3],      // 3D "graphics" matrix
 
61
                                                   0,0,0,1);
 
62
  if PitchEdit.value <> 0 then RotatePitch(PitchEdit.value{-11.4592},lRot);
 
63
  if RollEdit.value <> 0 then RotateRoll(RollEdit.value,lRot);
 
64
  if YawEdit.value <> 0 then RotateYaw(YawEdit.value,lRot);
 
65
  //lM := lRot;
 
66
    lM := MultiplyMatrices(lRot,lM);
 
67
 
 
68
(*  WriteNiftiMatrix (lHdr.NiftiHdr,
 
69
        lM.matrix[1,1],lM.matrix[1,2],lM.matrix[1,3],lM.matrix[1,4],
 
70
        lM.matrix[2,1],lM.matrix[2,2],lM.matrix[1,3],lM.matrix[2,4],
 
71
        lM.matrix[3,1],lM.matrix[3,2],lM.matrix[1,3],lM.matrix[3,4]);
 
72
 
 
73
  lHdr.Mat := lM;  *)
 
74
  //Caption := inttostr(random(888))+floattostr(lM.matrix[1,4]);
 
75
  XLabel.caption:= floattostr(lM.matrix[1,1])+'x'+floattostr(lM.matrix[1,2])+'x'+floattostr(lM.matrix[1,3])+'x'+floattostr(lM.matrix[1,4]);
 
76
  YLabel.caption:= floattostr(lM.matrix[2,1])+'x'+floattostr(lM.matrix[2,2])+'x'+floattostr(lM.matrix[2,3])+'x'+floattostr(lM.matrix[2,4]);
 
77
  ZLabel.caption:= floattostr(lM.matrix[3,1])+'x'+floattostr(lM.matrix[3,2])+'x'+floattostr(lM.matrix[3,3])+'x'+floattostr(lM.matrix[3,4]);
 
78
end;
 
79
(*procedure DrawLine(lIMage: TImage; lXmm,lYmm,lZmm,lXmm2,lYmm2,lZmm2: integer);
 
80
var
 
81
   lX,lY,lZ: integer;
 
82
begin
 
83
     lImage.Canvas.Pen.Color:=gBGImg.XBarClr;
 
84
     lImage.Canvas.Pen.Width := gBGImg.XBarThick;
 
85
     MMToImgCoord( lX,lY,lZ, lXmm,lYmm,lZmm);
 
86
        lImage.Canvas.MoveTo(lX,lY);
 
87
     MMToImgCoord( lX,lY,lZ, lXmm2,lYmm2,lZmm2);
 
88
     lImage.Canvas.LineTo(lX,lY);
 
89
end;*)
 
90
 
 
91
procedure TReorientForm.ReorientTimerTimer(Sender: TObject);
 
92
begin
 
93
     ReorientTimer.enabled := false;
 
94
     //ImgForm.CloseOverlayImgClick(nil);
 
95
 
 
96
     (*DrawLine(ImgForm.PGImage2,0,-104,0,0,72,0);//horizontal line on Sag
 
97
     DrawLine(ImgForm.PGImage2,0,0,78,0,0,-48);//horizontal line on Sag
 
98
     DrawLine(ImgForm.PGImage3,0,0,77,0,0,-48);//horizontal line on Sag
 
99
     DrawLine(ImgForm.PGImage3,-64,0,0,64,0,0);//horizontal line on Sag
 
100
      *)
 
101
     ApplyTransform(gMRIcroOverlay[kBGOverlayNum]);
 
102
   //MMToImgCoord(var lX,lY,lZ: integer; var lXmm,lYmm,lZmm: single);
 
103
end;
 
104
 
 
105
(*procedure TReorientForm.ReorientTimerTimer(Sender: TObject);
 
106
var
 
107
   lFilename: string;
 
108
begin
 
109
     ReorientTimer.enabled := false;
 
110
     ImgForm.CloseOverlayImgClick(nil);
 
111
     ReorientTimer.enabled := false;
 
112
     lFilename := 'C:\pas\Delphi\niftiview\grey.voi';
 
113
     ImgForm.LoadOverlay (lFilename);
 
114
end; *)
 
115
 
 
116
procedure TReorientForm.EditChange(Sender: TObject);
 
117
begin
 
118
   ReorientTimer.enabled := true;
 
119
end;
 
120
 
 
121
end.