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
00109 class QVImageCanvas: public QVCanvas, public QVPropertyContainer
00110 {
00111 Q_OBJECT
00112 public:
00117 QVImageCanvas(const QString name = QString(), QWidget *parent=0);
00118
00137 bool setColor(const QString &name, const QColor &color)
00138 { return setPropertyValue<QColor>("Color for " + name, color); }
00139
00141 bool setPrintTags(const QString &name, const bool &printTags)
00142 { return setPropertyValue<bool>("Print tags for " + name, printTags); }
00143
00151 bool setRadius(const QString &name, const int &radius)
00152 { return setPropertyValue<int>("Radius for " + name, radius); }
00153
00163 void setSaturationRange(const float low, const float high);
00164
00167 bool linkSelectedPolyline(QVPropertyContainer *destinationContainer, QString destinationPropName)
00168 {
00169 return linkProperty("poly select", destinationContainer, destinationPropName);
00170 }
00171
00174 bool linkSelectedRectangle(QVPropertyContainer *destinationContainer, QString destinationPropName)
00175 {
00176 return linkProperty("rect select", destinationContainer, destinationPropName);
00177 }
00178
00183 bool linkSelectedPolyline(QVPropertyContainer &destinationContainer, QString destinationPropName)
00184 {
00185 return linkSelectedPolyline(&destinationContainer, destinationPropName);
00186 }
00187
00192 bool linkSelectedRectangle(QVPropertyContainer &destinationContainer, QString destinationPropName)
00193 {
00194 return linkSelectedRectangle(&destinationContainer, destinationPropName);
00195 }
00196
00235 virtual void custom_viewer() { };
00236
00238 void setLowHigh(float low,float high)
00239 {
00240 std::cout << "DEPRECATED, use setSaturationRange instead" << std::endl;
00241 setSaturationRange(low, high);
00242 }
00243
00244 void unlink();
00245
00246 #ifndef DOXYGEN_IGNORE_THIS
00247 void viewer();
00248 #endif
00249
00250 public slots:
00251 void rectSelectedSlot(QRect rect);
00252 void polySelectedSlot(QPoint point, bool reset, TPolyMode mode);
00253 void circleSelectedSlot(QPoint center, float radius);
00254
00255 protected:
00256 bool linkUnspecifiedInputProperty(QVPropertyContainer *sourceContainer, QString sourcePropName, LinkType linkType = AsynchronousLink);
00257 bool linkUnspecifiedOutputProperty(QVPropertyContainer *destContainer, QString destPropName, LinkType linkType = AsynchronousLink);
00258 bool treatUnlinkInputProperty(QString destPropName, QVPropertyContainer *sourceCont, QString sourcePropName);
00259
00260 void draw(const QList<QPoint> &pointList, QColor color = Qt::red, bool printTags = false, int radius = 3);
00261 void draw(const QList<QPointF> &pointList, QColor color = Qt::red, bool printTags = false, double radius = 3);
00262 void draw(const QVPolyline &polyline, QColor color = Qt::red, bool printTags = false);
00263 void draw(const QVPolylineF &polylinef, QColor color = Qt::red, bool printTags = false);
00264 void draw(const QRect &rectangle, QColor color = Qt::red, bool printTags = false);
00265
00266 void closeEvent(QCloseEvent *event) { Q_UNUSED(event); emit closed(); }
00267 private:
00268
00269 const QColor getNextColor()
00270 {
00271 QColor color = qvColors[colorCursor++];
00272 colorCursor %= 10;
00273
00274 return color;
00275 }
00276
00277 float _low,_high;
00278 int colorCursor, contentLinkedBlocks;
00279
00280 signals:
00281 void closed();
00282
00283 };
00284
00285 Q_DECLARE_METATYPE(TPolyMode);
00286
00287 #endif