00001 //--------------------------------------------------------------------------- 00002 // 00003 // File: Txq2dLineSeg.h 00004 // 00005 // Purpose: Draw a line segment on the Txq2dCanvas 00006 00007 // Version: $Id: Txq2dLineSeg.h,v 1.5 2002/01/17 19:29:21 kgl Exp $ 00008 // 00009 // Author: Kelly G. Luetkemeyer 00010 // 00011 // modifed from the Txq2dLineSeg.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 00018 #ifndef TXQ2D_LINESEG_H 00019 #define TXQ2D_LINESEG_H 00020 00021 // std includes 00022 #include <cmath> 00023 #include <cfloat> 00024 00025 // Tx includes 00026 #include "Txq2dSeg.h" 00027 00042 class Txq2dLineSeg: public Txq2dSeg { 00043 00044 public: 00045 00050 Txq2dLineSeg(); 00051 00052 00062 Txq2dLineSeg(int x1, int y1, int x2, int y2); 00063 00071 Txq2dLineSeg(QPoint p1, QPoint p2); 00072 00080 Txq2dLineSeg(TxqDoublePoint p1, TxqDoublePoint p2); 00081 00091 Txq2dLineSeg(double x1, double y1, double x2, double y2); 00092 00096 virtual ~Txq2dLineSeg(); 00097 00102 void calculateParameters(); 00103 00108 void setBoundsToPoints(); 00109 00119 void setPoints(int x1, int y1, int x2, int y2); 00120 00128 void setPoints(QPoint p1, QPoint p2); 00129 00137 void setPoints(TxqDoublePoint p1, TxqDoublePoint p2); 00138 00148 void setPoints(double x1, double y1, double x2, double y2); 00149 00156 void setStartPoint(TxqDoublePoint sp); 00157 00165 void setStartPoint(int x, int y); 00166 00173 void setEndPoint(TxqDoublePoint ep); 00174 00182 void setEndPoint(int x, int y); 00183 00191 void setPointAndAngle(TxqDoublePoint sp, double myAngle); 00192 00196 void stretchToMax(); 00197 00204 void setAngle(double myAngle); 00205 00206 00212 void setSlope(double m); 00213 00217 double getSlope(); 00218 00224 void setIntercept(double b); 00225 00229 double getIntercept(); 00230 00236 int findY(int x); 00237 00243 double findY(double x); 00244 00250 int findX(int y) ; 00251 00257 double findX(double y); 00258 00265 TxqDoublePoint intersection(TxqDoublePoint p, double m); 00266 00272 TxqDoublePoint intersection(Txq2dLineSeg segline); 00273 00280 QPoint getPointAtPosition(int pixels); 00281 00287 bool inBetweenEnds(TxqDoublePoint p); 00288 00294 bool onLineSegment(TxqDoublePoint p); 00295 00300 void findCenterFromBounds(); 00301 00302 00307 void paint(QPainter* g ); 00308 00314 void dump(QTextStream *ts); 00315 00316 protected: 00317 00321 virtual void initialize(); 00322 00323 private: 00324 00325 // Class data members 00326 00330 double slope; 00331 00335 double intercept; 00336 00340 static const double MAX_SIZE; 00341 00345 int numPoints; 00346 }; 00347 00348 #endif 00349
Copyright Tech-X Corporation, all rights reserved.