Added a version save isinsnace function
Added wxPoint2DDouble git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@18190 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include <wx/resource.h>
|
||||
#include <wx/tooltip.h>
|
||||
#include <wx/busyinfo.h>
|
||||
#include <wx/geometry.h>
|
||||
%}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@@ -79,12 +80,6 @@ public:
|
||||
return tup;
|
||||
}
|
||||
|
||||
int __cmp__(const wxSize* sz) {
|
||||
if (! sz) return 1;
|
||||
if (*self == *sz) return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool __eq__(const wxSize& o) { return *self == o; }
|
||||
bool __ne__(const wxSize& o) { return *self != o; }
|
||||
}
|
||||
@@ -126,25 +121,18 @@ public:
|
||||
return tup;
|
||||
}
|
||||
|
||||
wxRealPoint __add__(const wxRealPoint* p) {
|
||||
if (! p) return *self;
|
||||
return *self + *p;
|
||||
wxRealPoint __add__(const wxRealPoint& p) {
|
||||
return *self + p;
|
||||
}
|
||||
|
||||
wxRealPoint __sub__(const wxRealPoint* p) {
|
||||
if (! p) return *self;
|
||||
return *self - *p;
|
||||
}
|
||||
|
||||
int __cmp__(const wxRealPoint* p) {
|
||||
if (! p) return 1;
|
||||
if (*self == *p) return 0;
|
||||
return -1;
|
||||
wxRealPoint __sub__(const wxRealPoint& p) {
|
||||
return *self - p;
|
||||
}
|
||||
|
||||
bool __eq__(const wxRealPoint& o) { return *self == o; }
|
||||
bool __ne__(const wxRealPoint& o) { return *self != o; }
|
||||
}
|
||||
|
||||
%pragma(python) addtoclass = "
|
||||
def __str__(self): return str(self.asTuple())
|
||||
def __repr__(self): return str(self.asTuple())
|
||||
@@ -180,25 +168,18 @@ public:
|
||||
return tup;
|
||||
}
|
||||
|
||||
wxPoint __add__(const wxPoint* p) {
|
||||
if (! p) return *self;
|
||||
return *self + *p;
|
||||
wxPoint __add__(const wxPoint& p) {
|
||||
return *self + p;
|
||||
}
|
||||
|
||||
wxPoint __sub__(const wxPoint* p) {
|
||||
if (! p) return *self;
|
||||
return *self - *p;
|
||||
}
|
||||
|
||||
int __cmp__(const wxPoint* p) {
|
||||
if (! p) return 1;
|
||||
if (*self == *p) return 0;
|
||||
return -1;
|
||||
wxPoint __sub__(const wxPoint& p) {
|
||||
return *self - p;
|
||||
}
|
||||
|
||||
bool __eq__(const wxPoint& o) { return *self == o; }
|
||||
bool __ne__(const wxPoint& o) { return *self != o; }
|
||||
}
|
||||
|
||||
%pragma(python) addtoclass = "
|
||||
def __str__(self): return str(self.asTuple())
|
||||
def __repr__(self): return str(self.asTuple())
|
||||
@@ -262,15 +243,8 @@ public:
|
||||
return tup;
|
||||
}
|
||||
|
||||
wxRect __add__(const wxRect* rect) {
|
||||
if (! rect) return *self;
|
||||
return *self + *rect;
|
||||
}
|
||||
|
||||
int __cmp__(const wxRect* rect) {
|
||||
if (! rect) return 1;
|
||||
if (*self == *rect) return 0;
|
||||
return -1;
|
||||
wxRect __add__(const wxRect& rect) {
|
||||
return *self + rect;
|
||||
}
|
||||
|
||||
bool __eq__(const wxRect& o) { return *self == o; }
|
||||
@@ -357,6 +331,88 @@ public:
|
||||
%}
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// wxPoint2Ds represent a point or a vector in a 2d coordinate system
|
||||
|
||||
class wxPoint2DDouble
|
||||
{
|
||||
public:
|
||||
double m_x;
|
||||
double m_y;
|
||||
|
||||
%name(x)double m_x;
|
||||
%name(y)double m_y;
|
||||
|
||||
wxPoint2DDouble( double x=0 , double y=0 );
|
||||
%name(wxPoint2DDoubleCopy)wxPoint2DDouble( const wxPoint2DDouble &pt );
|
||||
%name(wxPoint2DDoubleFromPoint)wxPoint2DDouble( const wxPoint &pt );
|
||||
|
||||
// two different conversions to integers, floor and rounding
|
||||
void GetFloor( int* OUTPUT , int* OUTPUT ) const;
|
||||
void GetRounded( int* OUTPUT , int* OUTPUT ) const;
|
||||
|
||||
double GetVectorLength() const;
|
||||
double GetVectorAngle() const ;
|
||||
void SetVectorLength( double length );
|
||||
void SetVectorAngle( double degrees );
|
||||
// LinkError: void SetPolarCoordinates( double angle , double length );
|
||||
// LinkError: void Normalize();
|
||||
%pragma(python) addtoclass = "
|
||||
def SetPolarCoordinates(self, angle, length):
|
||||
self.SetVectorLength(length)
|
||||
self.SetVectorAngle(angle)
|
||||
def Normalize(self):
|
||||
self.SetVectorLength(1.0)
|
||||
"
|
||||
|
||||
double GetDistance( const wxPoint2DDouble &pt ) const;
|
||||
double GetDistanceSquare( const wxPoint2DDouble &pt ) const;
|
||||
double GetDotProduct( const wxPoint2DDouble &vec ) const;
|
||||
double GetCrossProduct( const wxPoint2DDouble &vec ) const;
|
||||
|
||||
%addmethods {
|
||||
// the reflection of this point
|
||||
wxPoint2DDouble __neg__() { return -(*self); }
|
||||
|
||||
wxPoint2DDouble& __iadd__(const wxPoint2DDouble& pt) { return (*self) += pt; }
|
||||
wxPoint2DDouble& __isub__(const wxPoint2DDouble& pt) { return (*self) -= pt; }
|
||||
wxPoint2DDouble& __imul__(const wxPoint2DDouble& pt) { return (*self) *= pt; }
|
||||
wxPoint2DDouble& __idiv__(const wxPoint2DDouble& pt) { return (*self) /= pt; }
|
||||
|
||||
// TODO:
|
||||
//wxPoint2DDouble& operator*=(double n);
|
||||
//wxPoint2DDouble& operator*=(int n);
|
||||
//wxPoint2DDouble& operator/=(double n);
|
||||
//wxPoint2DDouble& operator/=(int n);
|
||||
|
||||
bool __eq__(const wxPoint2DDouble& pt) { return (*self) == pt; }
|
||||
bool __ne__(const wxPoint2DDouble& pt) { return (*self) != pt; }
|
||||
|
||||
PyObject* asTuple() {
|
||||
wxPyBeginBlockThreads();
|
||||
PyObject* tup = PyTuple_New(2);
|
||||
PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->m_x));
|
||||
PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->m_y));
|
||||
wxPyEndBlockThreads();
|
||||
return tup;
|
||||
}
|
||||
}
|
||||
|
||||
%pragma(python) addtoclass = "
|
||||
def __str__(self): return str(self.asTuple())
|
||||
def __repr__(self): return str(self.asTuple())
|
||||
def __len__(self): return len(self.asTuple())
|
||||
def __getitem__(self, index): return self.asTuple()[index]
|
||||
def __setitem__(self, index, val):
|
||||
if index == 0: self.m_x = val
|
||||
elif index == 1: self.m_yt = val
|
||||
else: raise IndexError
|
||||
def __nonzero__(self): return self.asTuple() != (0.0, 0.0)
|
||||
"
|
||||
};
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Miscellaneous functions
|
||||
|
||||
|
Reference in New Issue
Block a user