| 1 |
//--------------------------------------------------------------------------- |
| 2 |
// Z Rotation |
| 3 |
//--------------------------------------------------------------------------- |
| 4 |
#include <stdlib.h> |
| 5 |
#include "QRot.h" |
| 6 |
//--------------------------------------------------------------------------- |
| 7 |
QRot::QRot(int x,int y) :QCircuit(x,y) { |
| 8 |
Name = GetTypeStr(); |
| 9 |
Phase = 0; |
| 10 |
} |
| 11 |
//--------------------------------------------------------------------------- |
| 12 |
QRot::QRot(int x,int y, string Param) :QCircuit(x,y) { |
| 13 |
Name = GetTypeStr(); |
| 14 |
Phase = atof(Param.c_str()); |
| 15 |
} |
| 16 |
//--------------------------------------------------------------------------- |
| 17 |
void |
| 18 |
QRot::Draw(QDraw *qDraw) { |
| 19 |
int GridSize = qDraw->GetGridSize(); |
| 20 |
int UnitSize = qDraw->GetUnitSize(); |
| 21 |
|
| 22 |
int d = (GridSize-UnitSize)/2; |
| 23 |
int x1 = X * GridSize+d; |
| 24 |
int y1 = Y * GridSize+d; |
| 25 |
int x2 = x1 + UnitSize; |
| 26 |
int y2 = y1 + UnitSize; |
| 27 |
|
| 28 |
qDraw->SetBrushColor(clWhite); |
| 29 |
qDraw->FillRect(x1,y1,x2,y2); |
| 30 |
qDraw->SetBrushColor(clPurple); |
| 31 |
qDraw->FrameRect(x1,y1,x2,y2); |
| 32 |
qDraw->SetPenColor(clBlack); |
| 33 |
qDraw->SetBrushColor(clWhite); |
| 34 |
ostringstream os; |
| 35 |
os << Phase; |
| 36 |
qDraw->TextOut(x1+UnitSize/2,y1+UnitSize/2, os.str()); |
| 37 |
} |
| 38 |
//--------------------------------------------------------------------------- |
| 39 |
void |
| 40 |
QRot::Reverse(int y) { |
| 41 |
Y = y-Y; |
| 42 |
} |
| 43 |
//--------------------------------------------------------------------------- |
| 44 |
string |
| 45 |
QRot::GetCalcText(void) { |
| 46 |
ostringstream os; |
| 47 |
os << "ROT("; |
| 48 |
os << "q[" << Y << "],"; |
| 49 |
os << Phase << ")"; |
| 50 |
return os.str(); |
| 51 |
} |
| 52 |
//--------------------------------------------------------------------------- |
| 53 |
void |
| 54 |
QRot::DrawPS(QPSDraw *psDraw) { |
| 55 |
int GridSize = psDraw->GetGridSize(); |
| 56 |
int UnitSize = psDraw->GetUnitSize(); |
| 57 |
|
| 58 |
int d = (GridSize-UnitSize)/2; |
| 59 |
int x1 = X * GridSize+d; |
| 60 |
int y1 = Y * GridSize+d; |
| 61 |
int x2 = x1 + UnitSize; |
| 62 |
int y2 = y1 + UnitSize; |
| 63 |
|
| 64 |
psDraw->FillRect(x1,y1,x2,y2); |
| 65 |
|
| 66 |
psDraw->FillRect(x1,y1,x2,y2); |
| 67 |
psDraw->FrameRect(x1,y1,x2,y2); |
| 68 |
ostringstream os; |
| 69 |
os << Phase; |
| 70 |
psDraw->TextOut(x1+UnitSize/2,y1+UnitSize/2,os.str()); |
| 71 |
} |
| 72 |
//--------------------------------------------------------------------------- |
| 73 |
string |
| 74 |
QRot::GetParam(void) { |
| 75 |
ostringstream os; |
| 76 |
os << Phase; |
| 77 |
return os.str(); |
| 78 |
} |
| 79 |
//--------------------------------------------------------------------------- |
| 80 |
TRect QRot::GetOccupiedRect() { |
| 81 |
return TRect(X, Y, X + 1, Y + 1); |
| 82 |
} |
| 83 |
//-------------------------------------------------------------------------- |
| 84 |
QCircuit * |
| 85 |
QRot::Clone() { |
| 86 |
QRot * qc = new QRot(X, Y); |
| 87 |
qc->SetPhase(GetPhase()); |
| 88 |
return (QCircuit*)qc; |
| 89 |
} |
| 90 |
//--------------------------------------------------------------------------- |