|
Isis 3.0 Object Programmers' Reference |
Home |
00001 #ifndef RubberBandTool_h 00002 #define RubberBandTool_h 00003 00004 #include "Tool.h" 00005 00006 class QRect; 00007 class QPoint; 00008 00009 template <typename A> class QList; 00010 00011 namespace geos { 00012 namespace geom { 00013 class Geometry; 00014 } 00015 } 00016 00017 00018 namespace Isis { 00019 class MdiCubeViewport; 00020 00044 class RubberBandTool : public Tool { 00045 Q_OBJECT 00046 00047 public: 00048 static RubberBandTool *getInstance(QWidget *parent = NULL); 00049 virtual ~RubberBandTool(); 00050 00051 enum RubberBandMode { 00052 Angle, //<! Measure an angle 00053 Circle, //<! Draw a perfect circle 00054 Ellipse, //<! Draw an ellipse (oval) 00055 Line, //<! Draw a simple line 00056 Rectangle, //<! Draw a rectangle without any rotation (perfectly horizonal/verticle) 00057 RotatedRectangle, //<! Draw a rotatable rectangle 00058 Polygon, //<! Draw any closed shape 00059 SegmentedLine //<! Draw any open shape 00060 }; 00061 00062 static void enable(RubberBandMode mode, bool showIndicatorColors = false); 00063 void enableBanding(RubberBandMode mode, bool showIndicatorColors = false); 00064 00065 static void disable(); 00066 void disableBanding(); 00067 00068 static void drawActiveViewportOnly(bool activeOnly = false); 00069 void setDrawActiveViewportOnly(bool activeOnly = false); 00070 00071 static QList<QPoint> getVertices(); 00072 QList<QPoint> getFoundVertices(); 00073 00074 static RubberBandMode getMode(); 00075 RubberBandMode getCurrentMode(); 00076 static double getArea(); 00077 double getAreaMeasure(); 00078 static double getAngle(); 00079 double getAngleMeasure(); //<! Returns the angle measurement (in radians) 00080 00081 static geos::geom::Geometry *geometry(); 00082 geos::geom::Geometry *getGeometry(); 00083 static QRect rectangle(); 00084 QRect getRectangle(); 00085 static Qt::MouseButton mouseButton(); 00086 Qt::MouseButton getMouseButton(); 00087 void paintViewport(MdiCubeViewport *vp, QPainter *painter); 00088 00089 //<! This returns true if we can return complete & valid data. 00090 static bool isValid(); 00091 bool figureComplete(); 00092 bool figureValid(); 00093 00094 static bool isPoint(); 00095 bool figureIsPoint(); 00096 00097 static void allowPoints(unsigned int pixTolerance = 2); 00098 void enablePoints(unsigned int pixTolerance = 2); 00099 static void allowAllClicks(); 00100 void enableAllClicks(); 00101 00102 static void clear(); 00103 00104 public slots: 00105 void escapeKeyPress(); 00106 00107 signals: 00108 void modeChanged(); 00109 void bandingComplete(); 00110 void measureChange(); 00111 00112 protected: 00113 void enableRubberBandTool() {} 00114 void scaleChanged(); 00115 00116 protected slots: 00117 void mouseMove(QPoint p, Qt::MouseButton); 00118 void mouseDoubleClick(QPoint p); 00119 void mouseButtonPress(QPoint p, Qt::MouseButton s); 00120 void mouseButtonRelease(QPoint p, Qt::MouseButton s); 00121 00122 private: 00123 QPoint snapMouse(QPoint); 00124 RubberBandTool(QWidget *parent); 00125 00126 void repaint(); 00127 void paintVerticesConnected(QPainter *painter); 00128 void paintRectangle(QPoint upperLeft, QPoint lowerRight, QPainter *painter); 00129 void paintRectangle(QPoint upperLeft, QPoint upperRight, 00130 QPoint lowerLeft, QPoint lowerRight, QPainter *painter); 00131 00132 // This is used for rotated rectangle 00133 void calcRectCorners(QPoint corner1, QPoint corner2, QPoint &corner3, QPoint &corner4); 00134 00135 static RubberBandTool *p_instance; 00136 00137 void reset(); //<! This resets the member variables 00138 00139 bool p_mouseDown; //<! True if the mouse is pressed 00140 bool p_doubleClicking; //<! True if on second click of a double click 00141 bool p_tracking; //<! True if painting on mouse move 00142 bool p_allClicks; //<! Enables all mouse buttons for banding 00143 bool p_drawActiveOnly; //<! True if draw on active viewport only 00144 RubberBandMode p_bandingMode; //<! Current type of rubber band 00145 QList<QPoint> * p_vertices; //<! Known vertices pertaining to the current rubber band 00146 QPoint *p_mouseLoc; //<! Current mouse location, only valid of p_tracking 00147 Qt::MouseButton p_mouseButton; //<! Last mouse button status 00148 bool p_indicatorColors; //<! Color the first side of objects a different color, if it's significant 00149 unsigned int p_pointTolerance; //<! Tolerance for points (zero for no points) 00150 }; 00151 }; 00152 00153 #endif 00154