00001 //--------------------------------------------------------------------------- 00002 // 00003 // File: Txq2dPolygon.h 00004 // 00005 // Purpose: Draw a polygon on the Txq2dCanvas 00006 // 00007 // Version: $Id: Txq2dPolygon.h,v 1.5 2002/01/17 19:29:21 kgl Exp $ 00008 // 00009 // Author: Kelly G. Luetkemeyer 00010 // 00011 // modified from the TxPolygon java class: 00012 // Project: Tech-X Foundation Classes 00013 // David A. Alexander, Svetlana G. Shasharina, John R. Cary 00014 // Copyright (C) 1998-2000 Tech-X Corporation. All Rights Reserved. 00015 //--------------------------------------------------------------------------- 00016 00017 #ifndef TXQ2D_POLYGON_H 00018 #define TXQ2D_POLYGON_H 00019 00020 // Txq includes 00021 #include "Txq2dOutlined.h" 00022 00023 // Qt includes 00024 #include <qrect.h> 00025 00039 class Txq2dPolygon: public Txq2dOutlined { 00040 00041 public: 00045 Txq2dPolygon(); 00046 00054 Txq2dPolygon( const std::vector<int> &xpoints, const std::vector<int> &ypoints); 00055 00063 Txq2dPolygon( const std::vector<double> &xpoints, const std::vector<double> &ypoints); 00064 00071 Txq2dPolygon( const std::vector<QPoint> &points); 00072 00076 virtual ~Txq2dPolygon(); 00077 00081 void resetSegments(); 00082 00090 void makePolygon(int cx, int cy); 00091 00096 void updatePolarArrays(); 00097 00104 void addPoint(int x, int y); 00105 00112 void addPoint(double x, double y); 00113 00122 void setPoints(int x1, int y1, int x2, int y2); 00123 00132 void setPoints(double x1, double y1, double x2, double y2); 00133 00140 void setPoints(QPoint p1, QPoint p2); 00141 00149 void setPoints( const std::vector<int> &xpoints, const std::vector<int> &ypoints); 00150 00158 void setPoints( const std::vector<double> &xpoints, const std::vector<double> &ypoints); 00159 00166 void setPoints( const std::vector<QPoint> &points); 00167 00171 void clearPoints(); 00172 00176 void rotate(double delta); 00177 00184 void paint(QPainter *g); 00185 00190 void drawPolygon(QPainter *g); 00191 00192 protected: 00193 00197 void initialize(); 00198 00204 void dump(QTextStream *ts); 00205 00206 private: 00207 00208 00212 struct Polygon { 00213 QPointArray polyPoints; 00214 int numPoints; 00215 QRect rect; 00216 }; 00217 00221 Polygon polygon; 00222 00223 00224 }; 00225 #endif 00226
Copyright Tech-X Corporation, all rights reserved.