void Viewer::SetOrientation (Orientation o) { if (_orientation != o) { _orientation = o; Coord l, b, r, t; GetGraphicBox(l, b, r, t); Graphic* g = GraphicBlock::GetGraphic(); if ( _orientation == Normal || _orientation == Portrait || _orientation == Vertical ) { g->Rotate(90., l, b); g->Translate(t-b, 0.); } else if ( _orientation == Rotated || _orientation == Landscape || _orientation == Horizontal ) { g->Rotate(-90., l, b); g->Translate(0., r-l); } GraphicBlock::Update(); } }
void Grapher::Retranslate (Picture* p, float sx, float sy, float l, float b) { float ml, mb; Iterator i; for (p->First(i); !p->Done(i); p->Next(i)) { Graphic* kid = p->GetGraphic(i); kid->GetCenter(ml, mb); kid->Translate((ml-l)*sx, (mb-b)*sy); } }
void Grapher::Append (float x, float y) { float cx, cy; float effx, effy; effx = _origx + (x - _lorigx) * _hinc; effy = _origy + (y - _lorigy) * _vinc; Graphic* dot = _dot->Copy(); _dot_picture->Append(dot); dot->GetCenter(cx, cy); dot->Translate(effx-cx, effy-cy); }
void Grapher::InitVAxis () { for (int v = 1; v <= _vrange; v++) { char num[10]; sprintf(num, "%d", (int)_lorigy+v); TextGraphic* text = new TextGraphic(num, _vlabel); _vlabel_picture->Append(text); text->Translate(0.0, _vinc*(v-1)); _vaxis_picture->Align(Left, text, Right); Graphic* vaxis = _vaxis->Copy(); _vaxis_picture->Append(vaxis); vaxis->Translate(0.0, _vinc*v); } }
void Viewer::Reorient () { if ( _orientation == Rotated || _orientation == Landscape || _orientation == Horizontal ) { Coord l, b, r, t; GetGraphicBox(l, b, r, t); Graphic* g = GraphicBlock::GetGraphic(); g->Rotate(-90., l, b); g->Translate(0., r-l); } }
void Grapher::InitHAxis () { for (int h = 1; h <= _hrange; h++) { char num[10]; sprintf(num, "%d", (int)_lorigx+h); TextGraphic* text = new TextGraphic(num, _hlabel); _hlabel_picture->Append(text); text->Translate(_hinc*(h-1), 0.0); Graphic* haxis = _haxis->Copy(); _haxis_picture->Append(haxis); haxis->Translate(_hinc*h, 0.0); } }