00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00024
00025 #ifndef QVIMAGECANVAS_H
00026 #define QVIMAGECANVAS_H
00027
00028 #include <QPointF>
00029 #include <QVProcessingBlock>
00030 #include <QVPolyline>
00031 #include <QVPolylineF>
00032 #include "qvcanvas.h"
00033 #include "qvplot.h"
00034
00108 class QVImageCanvas: public QVCanvas, public QVPropertyContainer
00109 {
00110 Q_OBJECT
00111 public:
00116 QVImageCanvas(const QString name = QString(), QWidget *parent=0);
00117
00136 bool setColor(const QString &name, const QColor &color)
00137 { return setPropertyValue<QColor>("Color for " + name, color); }
00138
00140 bool setPrintTags(const QString &name, const bool &printTags)
00141 { return setPropertyValue<bool>("Print tags for " + name, printTags); }
00142
00150 bool setRadius(const QString &name, const int &radius)
00151 { return setPropertyValue<int>("Radius for " + name, radius); }
00152
00162 void setSaturationRange(const float low, const float high);
00163
00166 bool linkSelectedPolyline(QVPropertyContainer *destinationContainer, QString destinationPropName)
00167 {
00168 return linkProperty("poly select", destinationContainer, destinationPropName);
00169 }
00170
00173 bool linkSelectedRectangle(QVPropertyContainer *destinationContainer, QString destinationPropName)
00174 {
00175 return linkProperty("rect select", destinationContainer, destinationPropName);
00176 }
00177
00182 bool linkSelectedPolyline(QVPropertyContainer &destinationContainer, QString destinationPropName)
00183 {
00184 return linkSelectedPolyline(&destinationContainer, destinationPropName);
00185 }
00186
00191 bool linkSelectedRectangle(QVPropertyContainer &destinationContainer, QString destinationPropName)
00192 {
00193 return linkSelectedRectangle(&destinationContainer, destinationPropName);
00194 }
00195
00234 virtual void custom_viewer() { };
00235
00237 void setLowHigh(float low,float high)
00238 {
00239 std::cout << "DEPRECATED, use setSaturationRange instead" << std::endl;
00240 setSaturationRange(low, high);
00241 }
00242
00243 void unlink();
00244
00245 #ifndef DOXYGEN_IGNORE_THIS
00246 void viewer();
00247 #endif
00248
00249 public slots:
00250 void rectSelectedSlot(QRect rect);
00251 void polySelectedSlot(QPoint point, bool reset, TPolyMode mode);
00252 void circleSelectedSlot(QPoint center, float radius);
00253
00254 protected:
00255 bool linkUnspecifiedInputProperty(QVPropertyContainer *sourceContainer, QString sourcePropName, LinkType linkType = AsynchronousLink);
00256 bool linkUnspecifiedOutputProperty(QVPropertyContainer *destContainer, QString destPropName, LinkType linkType = AsynchronousLink);
00257 bool treatUnlinkInputProperty(QString destPropName, QVPropertyContainer *sourceCont, QString sourcePropName);
00258
00259 void draw(const QList<QPoint> &pointList, QColor color = Qt::red, bool printTags = false, int radius = 3);
00260 void draw(const QList<QPointF> &pointList, QColor color = Qt::red, bool printTags = false, double radius = 3);
00261 void draw(const QVPolyline &polyline, QColor color = Qt::red, bool printTags = false);
00262 void draw(const QVPolylineF &polylinef, QColor color = Qt::red, bool printTags = false);
00263 void draw(const QRect &rectangle, QColor color = Qt::red, bool printTags = false);
00264
00265 void closeEvent(QCloseEvent *event) { Q_UNUSED(event); emit closed(); }
00266 private:
00267
00268 const QColor getNextColor()
00269 {
00270 QColor color = qvColors[colorCursor++];
00271 colorCursor %= 10;
00272
00273 return color;
00274 }
00275
00276 float _low,_high;
00277 int colorCursor, contentLinkedBlocks;
00278
00279 signals:
00280 void closed();
00281
00282 };
00283
00284 Q_DECLARE_METATYPE(TPolyMode);
00285
00286 #endif