|
hipp
1.0
|
00001 /* 00002 Copyright 2011 Certec, Lund University, Sweden 00003 00004 This file is part of HIPP. 00005 00006 HIPP is free software: you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation, either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 HIPP is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with HIPP. If not, see <http://www.gnu.org/licenses/>. 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(int scaleX, int scaleY); 00066 00067 void addPoint(wxPoint* p); 00071 void addPoints(vector<wxPoint *> points); 00072 void simplify(); 00073 vector<wxPoint *> getPoints(){ return points; } 00074 00075 // void setLineWidth(int w); 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 // int bound_offset; 00088 vector<wxPoint *> points; 00089 }; 00090 } 00091 #endif
1.7.5.1