00001 //-------------------------------------------------------------------- 00002 // 00003 // File: TxqDrawable.h 00004 // 00005 // Purpose: Base class for drawable objects 00006 // 00007 // Version: $Id: TxqDrawable.h,v 1.9 2002/01/17 19:28:00 kgl Exp $ 00008 // 00009 // Author: Kelly G. Luetkemeyer 00010 // 00011 // modified from the TxqDrawable java class: 00012 // Project: Tech-X Foundation Classes 00013 // David A. Alexander, Svetlana G. Shasharina, John R. Cary 00014 // 00015 // Copyright (c) 2000 by Tech-X Corporation. All rights reserved. 00016 //--------------------------------------------------------------------------- 00017 00018 #ifndef TXQ_DRAWABLE_H 00019 #define TXQ_DRAWABLE_H 00020 00021 // system includes 00022 #include <vector> 00023 00024 #ifndef QT_ALTERNATE_QTSMANIP 00025 #define QT_ALTERNATE_QTSMANIP 00026 #endif 00027 00028 // Qt includes 00029 #include <qpoint.h> 00030 #include <qrect.h> 00031 #include <qcolor.h> 00032 #include <qtextstream.h> 00033 00034 // Txq includes 00035 #include <TxqDoublePoint.h> 00036 #include <TxqDefines.h> 00037 00050 class TxqDrawable 00051 { 00052 00053 public: 00054 00058 TxqDrawable(); 00059 00064 virtual void setColor(QColor c); 00065 00070 virtual QColor getColor(); 00071 00076 virtual void setPrintColor(QColor c); 00077 00082 QColor getPrintColor(); 00083 00090 virtual void setPrint(bool pr ); 00091 00097 void setTranslatable(bool b); 00098 00103 bool isTranslatable(); 00104 00110 void setResizable(bool b); 00111 00116 bool isResizable(); 00117 00123 void setRotatable(bool b); 00124 00129 bool isRotatable(); 00130 00136 void setControlable(bool b); 00137 00142 bool isControlable(); 00143 00148 void setLabel(QString *s); 00149 00154 QString* getLabel(); 00155 00160 void setLabelColor(QColor* c); 00161 00166 QColor* getLabelColor(); 00167 00172 void constrainY(); 00173 00177 bool isConstrainedY(); 00178 00183 void constrainX(); 00184 00188 bool isConstrainedX(); 00189 00194 void setLimitsX(int lower, int upper); 00195 00200 void setLimitsY(int lower, int upper); 00201 00206 bool isInXRange(int x); 00207 00212 bool isInYRange(int y); 00213 00218 void processRotation(double delta); 00219 00226 virtual void rotate(double delta); 00227 00232 void setRotationPoint(double x, double y); 00233 00238 void setRotationPoint(TxqDoublePoint point); 00239 00243 TxqDoublePoint getRotationPoint(); 00244 00249 void setAngle(double newAngle); 00250 00254 double getAngle(); 00255 00260 void findCenterPoint(); 00261 00267 void findCenterFromBounds(); 00268 00273 TxqDoublePoint getCenterPoint(); 00274 00279 void setCenterPoint(TxqDoublePoint cp); 00280 00285 void setCenterPoint(double x, double y); 00286 00290 virtual void setLocation(int x, int y) ; 00291 00299 void setDrawRect(int x, int y, int w, int h); 00300 00305 QRect* getDrawRect(); 00306 00311 void clicked(TxqDoublePoint* point); 00312 00316 QPoint* getClickedPoint() ; 00317 00321 void movedTo(QPoint* point); 00322 00326 QPoint* getMovedToPoint(); 00327 00331 QPoint* topPoint(); 00332 00336 QPoint* bottomPoint(); 00337 00341 QPoint* leftPoint(); 00342 00346 QPoint* rightPoint(); 00347 00351 void fireAction(QString s) ; 00352 00358 void setDump(bool df); 00359 00365 virtual void dump(QTextStream *ts); 00366 00370 virtual ~TxqDrawable(); 00371 00372 protected: 00373 00377 virtual void initialize(); 00378 00379 // Class data members 00380 bool translatable; 00381 bool resizable; 00382 bool rotatable; 00383 bool controlable; 00384 int controlFrameIndex; 00385 00386 // data members related to translation 00387 QPoint* movedToPoint; 00388 bool xConstrained; 00389 bool yConstrained; 00390 int xLowerLimit; 00391 int xUpperLimit; 00392 int yLowerLimit; 00393 int yUpperLimit; 00394 00395 // data member related to rotation 00396 static const double PI; 00397 static const double HALFPI; 00398 static const double THREEHALFPI; 00399 static const double TWOPI; 00400 TxqDoublePoint centerPoint; 00401 TxqDoublePoint rotationPoint; 00402 double angle; 00403 00404 // data members related to clicking and defining 00405 // physical bounds for mouse events 00406 TxqDoublePoint* clickedPoint; 00407 static const double physBoundsWidth; 00408 00412 QString* label; 00413 00417 QColor* labelColor; 00418 00422 QRect* drawRect; 00423 00427 QColor color; 00428 00432 QColor prcolor; 00433 00438 bool isPrint; 00439 00443 std::vector<TxqDoublePoint> points; 00444 00449 bool dumpFlag; 00450 }; 00451 #endif
Copyright Tech-X Corporation, all rights reserved.