00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "Viewport.h"
00027 #include "Device.h"
00028 #include "Projection.h"
00029
00030 Viewport::Viewport()
00031 {
00032
00033 }
00034
00035
00036 Viewport::~Viewport()
00037 {
00038
00039 }
00040
00041 int
00042 Viewport::update(void) {
00043 float Sx,Sy,Tx, Ty;
00044
00045 float PRTleft, PRTright, PRTtop, PRTbottom;
00046
00047 float length, width;
00048 length = theDevice->GetHeight();
00049 width = theDevice->GetWidth();;
00050
00051 PRTleft = portwindow[0];
00052 PRTright = portwindow[1];
00053 PRTbottom = portwindow[2];
00054 PRTtop = portwindow[3];
00055
00056 if (PRTleft < -1 || PRTright >1 || PRTtop >1 || PRTbottom <-1) {
00057 opserr << "Viewport::update() - PORTWINDOW must be in range { -1 1 -1 1}\n";
00058 return -1;
00059 }
00060
00061 Sx = (PRTright - PRTleft)/2 * width/2;
00062 Sy = (PRTtop - PRTbottom)/2 * length/2;
00063 Tx = Sx + (1 + PRTleft)*width/2;
00064 Ty = Sy + (1 + PRTbottom)*length/2;
00065
00066 TMat.Set( Sx, 0.0, 0.0, 0.0,
00067 0.0, Sy, 0.0, 0.0,
00068 0.0, 0.0, 1.0, 0.0,
00069 Tx, Ty, 0.0, 1.0);
00070
00071 return 0;
00072 }
00073
00074
00075 FACE &
00076 Viewport::transform(FACE &input)
00077 {
00078
00079
00080
00081 MYPOINT *point;
00082 FOR_EACH(point, input.pointList) {
00083 point->Transform(&TMat);
00084 };
00085
00086 return input;
00087 }
00088
00089
00090
00091 MYPOINT *
00092 Viewport::transformP(MYPOINT *input)
00093 {
00094 if (input != 0)
00095 input->Transform(&TMat);
00096
00097 return input;
00098 }
00099
00100
00101 void
00102 Viewport::setDevice(Device &device)
00103 {
00104 theDevice = &device;
00105 }
00106