Moved BAffineTransform from shared kit into interface kit. Still in BPrivate
namespace. Applied 80 char/line limit. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35955 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
c12643530e
commit
abb02bc4a4
@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2008, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2008-2010, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Stephen Deken, stephen.deken@gmail.com
|
||||
*/
|
||||
#ifndef _AFFINETRANSFORM_H
|
||||
#define _AFFINETRANSFORM_H
|
||||
#ifndef _AFFINE_TRANSFORM_H
|
||||
#define _AFFINE_TRANSFORM_H
|
||||
|
||||
#include <InterfaceDefs.h>
|
||||
|
||||
@ -19,9 +19,12 @@ namespace BPrivate {
|
||||
class BAffineTransform {
|
||||
public:
|
||||
BAffineTransform();
|
||||
BAffineTransform(const BAffineTransform& copyFrom);
|
||||
BAffineTransform(
|
||||
const BAffineTransform& copyFrom);
|
||||
virtual ~BAffineTransform();
|
||||
virtual BAffineTransform& operator=(const BAffineTransform& copyFrom);
|
||||
|
||||
virtual BAffineTransform& operator=(
|
||||
const BAffineTransform& copyFrom);
|
||||
|
||||
virtual bool operator==(
|
||||
const BAffineTransform& other) const;
|
||||
@ -33,58 +36,79 @@ public:
|
||||
|
||||
// Application
|
||||
BPoint Apply(const BPoint& point) const;
|
||||
void Apply(BPoint* point) const;
|
||||
void Apply(BPoint* points, uint32 count) const;
|
||||
|
||||
// Rotation
|
||||
void Rotate(float angle);
|
||||
void Rotate(const BPoint& center, float angle);
|
||||
BAffineTransform& RotateBySelf(float angle);
|
||||
BAffineTransform& RotateBySelf(const BPoint& center, float angle);
|
||||
BAffineTransform& RotateBySelf(const BPoint& center,
|
||||
float angle);
|
||||
BAffineTransform RotateByCopy(float angle) const;
|
||||
BAffineTransform RotateByCopy(const BPoint& center, float angle) const;
|
||||
BAffineTransform RotateByCopy(const BPoint& center,
|
||||
float angle) const;
|
||||
|
||||
// Translation
|
||||
void Translate(float deltaX, float deltaY);
|
||||
void Translate(const BPoint& delta);
|
||||
BAffineTransform& TranslateBySelf(float deltaX, float deltaY);
|
||||
BAffineTransform& TranslateBySelf(float deltaX,
|
||||
float deltaY);
|
||||
BAffineTransform& TranslateBySelf(const BPoint& delta);
|
||||
BAffineTransform TranslateByCopy(float deltaX, float deltaY) const;
|
||||
BAffineTransform TranslateByCopy(float deltaX,
|
||||
float deltaY) const;
|
||||
BAffineTransform TranslateByCopy(const BPoint& delta) const;
|
||||
|
||||
// Scaling
|
||||
void Scale(float scale);
|
||||
void Scale(const BPoint& center, float scale);
|
||||
void Scale(float scaleX, float scaleY);
|
||||
void Scale(const BPoint& center, float scaleX, float scaleY);
|
||||
void Scale(const BPoint& center, float scaleX,
|
||||
float scaleY);
|
||||
void Scale(const BPoint& scale);
|
||||
void Scale(const BPoint& center, const BPoint& scale);
|
||||
void Scale(const BPoint& center,
|
||||
const BPoint& scale);
|
||||
BAffineTransform& ScaleBySelf(float scale);
|
||||
BAffineTransform& ScaleBySelf(const BPoint& center, float scale);
|
||||
BAffineTransform& ScaleBySelf(const BPoint& center,
|
||||
float scale);
|
||||
BAffineTransform& ScaleBySelf(float scaleX, float scaleY);
|
||||
BAffineTransform& ScaleBySelf(const BPoint& center, float scaleX, float scaleY);
|
||||
BAffineTransform& ScaleBySelf(const BPoint& center,
|
||||
float scaleX, float scaleY);
|
||||
BAffineTransform& ScaleBySelf(const BPoint& scale);
|
||||
BAffineTransform& ScaleBySelf(const BPoint& center, const BPoint& scale);
|
||||
BAffineTransform& ScaleBySelf(const BPoint& center,
|
||||
const BPoint& scale);
|
||||
BAffineTransform ScaleByCopy(float scale) const;
|
||||
BAffineTransform ScaleByCopy(const BPoint& center, float scale) const;
|
||||
BAffineTransform ScaleByCopy(float scaleX, float scaleY) const;
|
||||
BAffineTransform ScaleByCopy(const BPoint& center, float scaleX, float scaleY) const;
|
||||
BAffineTransform ScaleByCopy(const BPoint& center,
|
||||
float scale) const;
|
||||
BAffineTransform ScaleByCopy(float scaleX,
|
||||
float scaleY) const;
|
||||
BAffineTransform ScaleByCopy(const BPoint& center,
|
||||
float scaleX, float scaleY) const;
|
||||
BAffineTransform ScaleByCopy(const BPoint& scale) const;
|
||||
BAffineTransform ScaleByCopy(const BPoint& center, const BPoint& scale) const;
|
||||
BAffineTransform ScaleByCopy(const BPoint& center,
|
||||
const BPoint& scale) const;
|
||||
|
||||
// Shearing
|
||||
void Shear(float shearX, float shearY);
|
||||
void Shear(const BPoint& center, float shearX, float shearY);
|
||||
void Shear(const BPoint& center, float shearX,
|
||||
float shearY);
|
||||
void Shear(const BPoint& shear);
|
||||
void Shear(const BPoint& center, const BPoint& shear);
|
||||
void Shear(const BPoint& center,
|
||||
const BPoint& shear);
|
||||
|
||||
BAffineTransform& ShearBySelf(float shearX, float shearY);
|
||||
BAffineTransform& ShearBySelf(const BPoint& center, float shearX, float shearY);
|
||||
BAffineTransform& ShearBySelf(const BPoint& center,
|
||||
float shearX, float shearY);
|
||||
BAffineTransform& ShearBySelf(const BPoint& shear);
|
||||
BAffineTransform& ShearBySelf(const BPoint& center, const BPoint& shear);
|
||||
BAffineTransform ShearByCopy(float shearX, float shearY) const;
|
||||
BAffineTransform ShearByCopy(const BPoint& center, float shearX, float shearY) const;
|
||||
BAffineTransform& ShearBySelf(const BPoint& center,
|
||||
const BPoint& shear);
|
||||
BAffineTransform ShearByCopy(float shearX,
|
||||
float shearY) const;
|
||||
BAffineTransform ShearByCopy(const BPoint& center,
|
||||
float shearX, float shearY) const;
|
||||
BAffineTransform ShearByCopy(const BPoint& shear) const;
|
||||
BAffineTransform ShearByCopy(const BPoint& center, const BPoint& shear) const;
|
||||
BAffineTransform ShearByCopy(const BPoint& center,
|
||||
const BPoint& shear) const;
|
||||
|
||||
private:
|
||||
void _Rotate(float angle);
|
||||
@ -94,6 +118,7 @@ private:
|
||||
|
||||
void _TransformPoint(BPoint& point) const;
|
||||
|
||||
private:
|
||||
agg::trans_affine fTransformMatrix;
|
||||
};
|
||||
|
||||
@ -101,4 +126,4 @@ private:
|
||||
|
||||
using namespace BPrivate;
|
||||
|
||||
#endif // _AFFINETRANSFORM_H
|
||||
#endif // _AFFINE_TRANSFORM_H
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2008-2010, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -9,14 +9,17 @@
|
||||
#include <AffineTransform.h>
|
||||
#include <Point.h>
|
||||
|
||||
|
||||
BAffineTransform::BAffineTransform()
|
||||
: fTransformMatrix()
|
||||
:
|
||||
fTransformMatrix()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BAffineTransform::BAffineTransform(const BAffineTransform& copyFrom)
|
||||
: fTransformMatrix(copyFrom.fTransformMatrix)
|
||||
:
|
||||
fTransformMatrix(copyFrom.fTransformMatrix)
|
||||
{
|
||||
}
|
||||
|
||||
@ -62,49 +65,27 @@ BAffineTransform::TransformationChanged() const
|
||||
BPoint
|
||||
BAffineTransform::Apply(const BPoint& point) const
|
||||
{
|
||||
BPoint rval(point);
|
||||
_TransformPoint(rval);
|
||||
return rval;
|
||||
BPoint result(point);
|
||||
_TransformPoint(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BAffineTransform::Apply(BPoint* point) const
|
||||
{
|
||||
if (point)
|
||||
_TransformPoint(*point);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BAffineTransform::Apply(BPoint* points, uint32 count) const
|
||||
{
|
||||
for (uint32 i = 0; i < count; ++i)
|
||||
_TransformPoint(points[i]);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BAffineTransform::_Rotate(float angle)
|
||||
{
|
||||
if (angle != 0.0)
|
||||
fTransformMatrix.multiply(agg::trans_affine_rotation(angle));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BAffineTransform::_Scale(float scaleX, float scaleY)
|
||||
{
|
||||
if (scaleX != 0.0 || scaleY != 0.0)
|
||||
fTransformMatrix.multiply(agg::trans_affine_scaling(scaleX, scaleY));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BAffineTransform::_Translate(float deltaX, float deltaY)
|
||||
{
|
||||
if (deltaX != 0.0 || deltaY != 0.0)
|
||||
fTransformMatrix.multiply(agg::trans_affine_translation(deltaX, deltaY));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BAffineTransform::_Shear(float shearX, float shearY)
|
||||
{
|
||||
if (shearX != 0.0 || shearY != 0.0)
|
||||
fTransformMatrix.multiply(agg::trans_affine_skewing(shearX, shearY));
|
||||
if (points) {
|
||||
for (uint32 i = 0; i < count; ++i)
|
||||
_TransformPoint(points[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -320,7 +301,8 @@ BAffineTransform::ScaleByCopy(float scaleX, float scaleY) const
|
||||
|
||||
|
||||
BAffineTransform
|
||||
BAffineTransform::ScaleByCopy(const BPoint& center, float scaleX, float scaleY) const
|
||||
BAffineTransform::ScaleByCopy(const BPoint& center, float scaleX,
|
||||
float scaleY) const
|
||||
{
|
||||
BAffineTransform copy(*this);
|
||||
copy.Scale(center, scaleX, scaleY);
|
||||
@ -416,7 +398,8 @@ BAffineTransform::ShearByCopy(float shearX, float shearY) const
|
||||
|
||||
|
||||
BAffineTransform
|
||||
BAffineTransform::ShearByCopy(const BPoint& center, float shearX, float shearY) const
|
||||
BAffineTransform::ShearByCopy(const BPoint& center, float shearX,
|
||||
float shearY) const
|
||||
{
|
||||
BAffineTransform copy(*this);
|
||||
copy.Shear(center, shearX, shearY);
|
||||
@ -442,6 +425,43 @@ BAffineTransform::ShearByCopy(const BPoint& center, const BPoint& shear) const
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
void
|
||||
BAffineTransform::_Rotate(float angle)
|
||||
{
|
||||
if (angle != 0.0)
|
||||
fTransformMatrix.multiply(agg::trans_affine_rotation(angle));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BAffineTransform::_Scale(float scaleX, float scaleY)
|
||||
{
|
||||
if (scaleX != 0.0 || scaleY != 0.0)
|
||||
fTransformMatrix.multiply(agg::trans_affine_scaling(scaleX, scaleY));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BAffineTransform::_Translate(float deltaX, float deltaY)
|
||||
{
|
||||
if (deltaX != 0.0 || deltaY != 0.0) {
|
||||
fTransformMatrix.multiply(
|
||||
agg::trans_affine_translation(deltaX, deltaY));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BAffineTransform::_Shear(float shearX, float shearY)
|
||||
{
|
||||
if (shearX != 0.0 || shearY != 0.0)
|
||||
fTransformMatrix.multiply(agg::trans_affine_skewing(shearX, shearY));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BAffineTransform::_TransformPoint(BPoint& point) const
|
||||
{
|
@ -33,6 +33,7 @@ SEARCH_SOURCE += [ FDirName $(SUBDIR) layouter ] ;
|
||||
|
||||
MergeObject <libbe>interface_kit.o :
|
||||
AbstractLayoutItem.cpp
|
||||
AffineTransform.cpp
|
||||
Alert.cpp
|
||||
Alignment.cpp
|
||||
Bitmap.cpp
|
||||
|
@ -12,7 +12,6 @@ UsePrivateHeaders kernel libroot ;
|
||||
|
||||
StaticLibrary libshared.a :
|
||||
AboutWindow.cpp
|
||||
AffineTransform.cpp
|
||||
CalendarView.cpp
|
||||
ColorQuantizer.cpp
|
||||
CommandPipe.cpp
|
||||
|
Loading…
Reference in New Issue
Block a user