1/*
2 * Copyright 2006-2009, Haiku.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		Stephan Aßmus <superstippi@gmx.de>
7 */
8
9#include "CanvasTransformBox.h"
10
11#include "CanvasView.h"
12
13
14// constructor
15CanvasTransformBox::CanvasTransformBox(CanvasView* view)
16	:
17	TransformBox(view, BRect(0.0, 0.0, 1.0, 1.0)),
18
19	fCanvasView(view),
20	fParentTransform()
21{
22}
23
24
25// destructor
26CanvasTransformBox::~CanvasTransformBox()
27{
28}
29
30
31// TransformFromCanvas
32void
33CanvasTransformBox::TransformFromCanvas(BPoint& point) const
34{
35	fParentTransform.InverseTransform(&point);
36	fCanvasView->ConvertFromCanvas(&point);
37}
38
39
40// TransformToCanvas
41void
42CanvasTransformBox::TransformToCanvas(BPoint& point) const
43{
44	fCanvasView->ConvertToCanvas(&point);
45	fParentTransform.Transform(&point);
46}
47
48
49// ZoomLevel
50float
51CanvasTransformBox::ZoomLevel() const
52{
53	return fCanvasView->ZoomLevel();
54}
55
56
57// ViewSpaceRotation
58double
59CanvasTransformBox::ViewSpaceRotation() const
60{
61	Transformable t(*this);
62	t.Multiply(fParentTransform);
63	return t.rotation() * 180.0 / M_PI;
64}
65