[haiku-commits] r35955 - in haiku/trunk: headers/os/interface headers/private/shared src/kits/interface src/kits/shared

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 26 Mar 2010 12:20:54 +0100 (CET)

Author: stippi
Date: 2010-03-26 12:20:53 +0100 (Fri, 26 Mar 2010)
New Revision: 35955
Changeset: http://dev.haiku-os.org/changeset/35955/haiku

Added:
   haiku/trunk/headers/os/interface/AffineTransform.h
   haiku/trunk/src/kits/interface/AffineTransform.cpp
Removed:
   haiku/trunk/headers/private/shared/AffineTransform.h
   haiku/trunk/src/kits/shared/AffineTransform.cpp
Modified:
   haiku/trunk/src/kits/interface/Jamfile
   haiku/trunk/src/kits/shared/Jamfile
Log:
Moved BAffineTransform from shared kit into interface kit. Still in BPrivate
namespace. Applied 80 char/line limit.


Copied: haiku/trunk/headers/os/interface/AffineTransform.h (from rev 35937, 
haiku/trunk/headers/private/shared/AffineTransform.h)
===================================================================
--- haiku/trunk/headers/os/interface/AffineTransform.h                          
(rev 0)
+++ haiku/trunk/headers/os/interface/AffineTransform.h  2010-03-26 11:20:53 UTC 
(rev 35955)
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2008-2010, Haiku, Inc. All Rights Reserved.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ *             Stephen Deken, stephen.deken@xxxxxxxxx
+ */
+#ifndef _AFFINE_TRANSFORM_H
+#define _AFFINE_TRANSFORM_H
+
+#include <InterfaceDefs.h>
+
+#include <agg_trans_affine.h>
+
+class BPoint;
+
+namespace BPrivate {
+
+class BAffineTransform {
+public:
+                                                                       
BAffineTransform();
+                                                                       
BAffineTransform(
+                                                                               
const BAffineTransform& copyFrom);
+               virtual                                         
~BAffineTransform();
+
+               virtual BAffineTransform&       operator=(
+                                                                               
const BAffineTransform& copyFrom);
+
+               virtual bool                            operator==(
+                                                                               
const BAffineTransform& other) const;
+               virtual bool                            operator!=(
+                                                                               
const BAffineTransform& other) const;
+
+       // Callbacks
+               virtual void                            TransformationChanged() 
const;
+
+       // 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        RotateByCopy(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(const 
BPoint& delta);
+                               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& scale);
+                               void                            Scale(const 
BPoint& center,
+                                                                               
const BPoint& scale);
+                               BAffineTransform&       ScaleBySelf(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& 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& 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& 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& 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        ShearByCopy(const 
BPoint& shear) const;
+                               BAffineTransform        ShearByCopy(const 
BPoint& center,
+                                                                               
const BPoint& shear) const;
+
+private:
+                               void                            _Rotate(float 
angle);
+                               void                            _Scale(float 
scaleX, float scaleY);
+                               void                            
_Translate(float deltaX, float deltaY);
+                               void                            _Shear(float 
shearX, float shearY);
+
+                               void                            
_TransformPoint(BPoint& point) const;
+
+private:
+                               agg::trans_affine       fTransformMatrix;
+};
+
+} // namespace BPrivate
+
+using namespace BPrivate;
+
+#endif // _AFFINE_TRANSFORM_H

Copied: haiku/trunk/src/kits/interface/AffineTransform.cpp (from rev 35937, 
haiku/trunk/src/kits/shared/AffineTransform.cpp)
===================================================================
--- haiku/trunk/src/kits/interface/AffineTransform.cpp                          
(rev 0)
+++ haiku/trunk/src/kits/interface/AffineTransform.cpp  2010-03-26 11:20:53 UTC 
(rev 35955)
@@ -0,0 +1,473 @@
+/*
+ * Copyright 2008-2010, Haiku, Inc. All Rights Reserved.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ *             Stephen Deken, stephen.deken@xxxxxxxxx
+ */
+
+#include <AffineTransform.h>
+#include <Point.h>
+
+
+BAffineTransform::BAffineTransform()
+       :
+       fTransformMatrix()
+{
+}
+
+
+BAffineTransform::BAffineTransform(const BAffineTransform& copyFrom)
+       :
+       fTransformMatrix(copyFrom.fTransformMatrix)
+{
+}
+
+
+BAffineTransform::~BAffineTransform()
+{
+}
+
+
+BAffineTransform&
+BAffineTransform::operator=(const BAffineTransform& copyFrom)
+{
+       if (copyFrom != *this) {
+               fTransformMatrix.reset();
+               fTransformMatrix.multiply(copyFrom.fTransformMatrix);
+               TransformationChanged();
+       }
+       return *this;
+}
+
+
+bool
+BAffineTransform::operator==(const BAffineTransform& other) const
+{
+       return fTransformMatrix == other.fTransformMatrix;
+}
+
+
+bool
+BAffineTransform::operator!=(const BAffineTransform& other) const
+{
+       return fTransformMatrix != other.fTransformMatrix;
+}
+
+
+void
+BAffineTransform::TransformationChanged() const
+{
+       // default implementation does nothing
+}
+
+
+BPoint
+BAffineTransform::Apply(const BPoint& point) const
+{
+       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
+{
+       if (points) {
+               for (uint32 i = 0; i < count; ++i)
+                       _TransformPoint(points[i]);
+       }
+}
+
+
+void
+BAffineTransform::Rotate(float angle)
+{
+       _Rotate(angle);
+       TransformationChanged();
+}
+
+
+void
+BAffineTransform::Rotate(const BPoint& center, float angle)
+{
+       _Translate(-center.x, -center.y);
+       _Rotate(angle);
+       _Translate(center.x, center.y);
+       TransformationChanged();
+}
+
+
+BAffineTransform&
+BAffineTransform::RotateBySelf(float angle)
+{
+       Rotate(angle);
+       return *this;
+}
+
+
+BAffineTransform&
+BAffineTransform::RotateBySelf(const BPoint& center, float angle)
+{
+       Rotate(center, angle);
+       return *this;
+}
+
+
+BAffineTransform
+BAffineTransform::RotateByCopy(float angle) const
+{
+       BAffineTransform copy(*this);
+       copy.Rotate(angle);
+       return copy;
+}
+
+
+BAffineTransform
+BAffineTransform::RotateByCopy(const BPoint& center, float angle) const
+{
+       BAffineTransform copy(*this);
+       copy.Rotate(center, angle);
+       return copy;
+}
+
+
+void
+BAffineTransform::Translate(float deltaX, float deltaY)
+{
+       _Translate(deltaX, deltaY);
+       TransformationChanged();
+}
+
+
+void
+BAffineTransform::Translate(const BPoint& delta)
+{
+       Translate(delta.x, delta.y);
+}
+
+
+BAffineTransform&
+BAffineTransform::TranslateBySelf(float deltaX, float deltaY)
+{
+       Translate(deltaX, deltaY);
+       return *this;
+}
+
+
+BAffineTransform&
+BAffineTransform::TranslateBySelf(const BPoint& delta)
+{
+       return TranslateBySelf(delta.x, delta.y);
+}
+
+
+BAffineTransform
+BAffineTransform::TranslateByCopy(float deltaX, float deltaY) const
+{
+       BAffineTransform copy(*this);
+       copy.Translate(deltaX, deltaY);
+       return copy;
+}
+
+
+BAffineTransform
+BAffineTransform::TranslateByCopy(const BPoint& delta) const
+{
+       return TranslateByCopy(delta.x, delta.y);
+}
+
+
+void
+BAffineTransform::Scale(float scale)
+{
+       Scale(scale, scale);
+}
+
+
+void
+BAffineTransform::Scale(const BPoint& center, float scale)
+{
+       Scale(center, scale, scale);
+}
+
+
+void
+BAffineTransform::Scale(float scaleX, float scaleY)
+{
+       _Scale(scaleX, scaleY);
+       TransformationChanged();
+}
+
+
+void
+BAffineTransform::Scale(const BPoint& center, float scaleX, float scaleY)
+{
+       _Translate(-center.x, -center.y);
+       _Scale(scaleX, scaleY);
+       _Translate(center.x, center.y);
+       TransformationChanged();
+}
+
+
+void
+BAffineTransform::Scale(const BPoint& scale)
+{
+       Scale(scale.x, scale.y);
+}
+
+
+void
+BAffineTransform::Scale(const BPoint& center, const BPoint& scale)
+{
+       Scale(center, scale.x, scale.y);
+}
+
+
+BAffineTransform&
+BAffineTransform::ScaleBySelf(float scale)
+{
+       return ScaleBySelf(scale, scale);
+}
+
+
+BAffineTransform&
+BAffineTransform::ScaleBySelf(const BPoint& center, float scale)
+{
+       return ScaleBySelf(center, scale, scale);
+}
+
+
+BAffineTransform&
+BAffineTransform::ScaleBySelf(float scaleX, float scaleY)
+{
+       Scale(scaleX, scaleY);
+       return *this;
+}
+
+
+BAffineTransform&
+BAffineTransform::ScaleBySelf(const BPoint& center, float scaleX, float scaleY)
+{
+       Scale(center, scaleX, scaleY);
+       return *this;
+}
+
+
+BAffineTransform&
+BAffineTransform::ScaleBySelf(const BPoint& scale)
+{
+       return ScaleBySelf(scale.x, scale.y);
+}
+
+
+BAffineTransform&
+BAffineTransform::ScaleBySelf(const BPoint& center, const BPoint& scale)
+{
+       return ScaleBySelf(center, scale.x, scale.y);
+}
+
+
+BAffineTransform
+BAffineTransform::ScaleByCopy(float scale) const
+{
+       return ScaleByCopy(scale, scale);
+}
+
+
+BAffineTransform
+BAffineTransform::ScaleByCopy(const BPoint& center, float scale) const
+{
+       return ScaleByCopy(center, scale, scale);
+}
+
+
+BAffineTransform
+BAffineTransform::ScaleByCopy(float scaleX, float scaleY) const
+{
+       BAffineTransform copy(*this);
+       copy.Scale(scaleX, scaleY);
+       return copy;
+}
+
+
+BAffineTransform
+BAffineTransform::ScaleByCopy(const BPoint& center, float scaleX,
+       float scaleY) const
+{
+       BAffineTransform copy(*this);
+       copy.Scale(center, scaleX, scaleY);
+       return copy;
+}
+
+
+BAffineTransform
+BAffineTransform::ScaleByCopy(const BPoint& scale) const
+{
+       return ScaleByCopy(scale.x, scale.y);
+}
+
+
+BAffineTransform
+BAffineTransform::ScaleByCopy(const BPoint& center, const BPoint& scale) const
+{
+       return ScaleByCopy(center, scale.x, scale.y);
+}
+
+
+void
+BAffineTransform::Shear(float shearX, float shearY)
+{
+       _Shear(shearX, shearY);
+       TransformationChanged();
+}
+
+
+void
+BAffineTransform::Shear(const BPoint& center, float shearX, float shearY)
+{
+       _Translate(-center.x, -center.y);
+       _Shear(shearX, shearY);
+       _Translate(center.x, center.y);
+       TransformationChanged();
+}
+
+
+void
+BAffineTransform::Shear(const BPoint& shear)
+{
+       Shear(shear.x, shear.y);
+}
+
+
+void
+BAffineTransform::Shear(const BPoint& center, const BPoint& shear)
+{
+       Shear(center, shear.x, shear.y);
+}
+
+
+BAffineTransform&
+BAffineTransform::ShearBySelf(float shearX, float shearY)
+{
+       Shear(shearX, shearY);
+       return *this;
+}
+
+
+BAffineTransform&
+BAffineTransform::ShearBySelf(const BPoint& center, float shearX, float shearY)
+{
+       Shear(center, shearX, shearY);
+       return *this;
+}
+
+
+BAffineTransform&
+BAffineTransform::ShearBySelf(const BPoint& shear)
+{
+       Shear(shear);
+       return *this;
+}
+
+
+BAffineTransform&
+BAffineTransform::ShearBySelf(const BPoint& center, const BPoint& shear)
+{
+       Shear(center, shear);
+       return *this;
+}
+
+
+BAffineTransform
+BAffineTransform::ShearByCopy(float shearX, float shearY) const
+{
+       BAffineTransform copy(*this);
+       copy.Shear(shearX, shearY);
+       return copy;
+}
+
+
+BAffineTransform
+BAffineTransform::ShearByCopy(const BPoint& center, float shearX,
+       float shearY) const
+{
+       BAffineTransform copy(*this);
+       copy.Shear(center, shearX, shearY);
+       return copy;
+}
+
+
+BAffineTransform
+BAffineTransform::ShearByCopy(const BPoint& shear) const
+{
+       BAffineTransform copy(*this);
+       copy.Shear(shear);
+       return copy;
+}
+
+
+BAffineTransform
+BAffineTransform::ShearByCopy(const BPoint& center, const BPoint& shear) const
+{
+       BAffineTransform copy(*this);
+       copy.Shear(center, shear);
+       return copy;
+}
+
+
+// #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
+{
+       double x = point.x;
+       double y = point.y;
+       fTransformMatrix.transform(&x, &y);
+       point.x = x;
+       point.y = y;
+}

Modified: haiku/trunk/src/kits/interface/Jamfile
===================================================================
--- haiku/trunk/src/kits/interface/Jamfile      2010-03-26 10:43:51 UTC (rev 
35954)
+++ haiku/trunk/src/kits/interface/Jamfile      2010-03-26 11:20:53 UTC (rev 
35955)
@@ -33,6 +33,7 @@
 
 MergeObject <libbe>interface_kit.o :
        AbstractLayoutItem.cpp
+       AffineTransform.cpp
        Alert.cpp
        Alignment.cpp
        Bitmap.cpp

Modified: haiku/trunk/src/kits/shared/Jamfile
===================================================================
--- haiku/trunk/src/kits/shared/Jamfile 2010-03-26 10:43:51 UTC (rev 35954)
+++ haiku/trunk/src/kits/shared/Jamfile 2010-03-26 11:20:53 UTC (rev 35955)
@@ -12,7 +12,6 @@
 
 StaticLibrary libshared.a :
        AboutWindow.cpp
-       AffineTransform.cpp
        CalendarView.cpp
        ColorQuantizer.cpp
        CommandPipe.cpp


Other related posts:

  • » [haiku-commits] r35955 - in haiku/trunk: headers/os/interface headers/private/shared src/kits/interface src/kits/shared - superstippi