Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __HIPPPOLYLINE_H__
00022 #define __HIPPPOLYLINE_H__
00023
00024 #include <wx/docview.h>
00025 #include "HippShape.h"
00026 #include <xercesc/util/XMLString.hpp>
00027 #include <iostream>
00028
00029 using namespace xercesc;
00030 using namespace std;
00031 namespace hipp {
00032
00047 class HippPolyline: public HippShape {
00048 public:
00049 HippPolyline(void);
00050 ~HippPolyline(void);
00051
00052 void LoadObject(const xercesc::Attributes& attrs, const XMLCh* const localname=XMLString::transcode("polyline"));
00053 ostream& SaveObject(ostream& stream);
00054
00055 ShapeType getShapeType(){
00056 if(isFilled()) return Polygon;
00057 else return Polyline;
00058 }
00059
00060 const wxRect& getBounds() const;
00061 bool containsPoint(wxPoint p) const;
00062 void OnDraw(Cairo::RefPtr<Cairo::Context> context, bool isHaptic = true) const;
00063 virtual HippPolyline* clone() const;
00064 void move(int diffX, int diffY);
00065 void zoom(double scaleX, double scaleY);
00066
00067 void addPoint(wxPoint* p);
00071 void addPoints(vector<wxPoint *> points);
00072 void simplify();
00073 vector<wxPoint *> getPoints(){ return points; }
00074
00075
00076
00077 bool pointInPolygon(int x, int y) const;
00078
00079 private:
00080 list<wxPoint *> DouglasPeucker(list<wxPoint *> pts, double error);
00081
00082 static double distance(wxPoint* a, wxPoint* b){
00083 return sqrt(pow((double)(a->x - b->x),2.0) + pow((double)(a->y - b->y),2.0));
00084 }
00085
00086 wxRect boundingRect;
00087
00088 vector<wxPoint *> points;
00089 };
00090 }
00091 #endif