Tulip  4.6.0
Better Visualization Through Research
library/tulip-gui/include/tulip/CaptionGraphicsSubItems.h
00001 /*
00002  *
00003  * This file is part of Tulip (www.tulip-software.org)
00004  *
00005  * Authors: David Auber and the Tulip development Team
00006  * from LaBRI, University of Bordeaux
00007  *
00008  * Tulip is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU Lesser General Public License
00010  * as published by the Free Software Foundation, either version 3
00011  * of the License, or (at your option) any later version.
00012  *
00013  * Tulip is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016  * See the GNU General Public License for more details.
00017  *
00018  */
00019 ///@cond DOXYGEN_HIDDEN
00020 
00021 #ifndef CAPTIONGRAPHICSSUBITEMS_H
00022 #define CAPTIONGRAPHICSSUBITEMS_H
00023 
00024 #include <QGraphicsPixmapItem>
00025 #include <QObject>
00026 
00027 class QGradient;
00028 
00029 namespace tlp {
00030 
00031 class ConfigurationIconItem : public QObject, public QGraphicsPixmapItem {
00032 
00033   Q_OBJECT
00034 
00035 public :
00036 
00037   ConfigurationIconItem() {
00038 
00039   }
00040 
00041 signals :
00042 
00043   void configurationIconPressed();
00044 
00045 protected :
00046 
00047   void mousePressEvent( QGraphicsSceneMouseEvent *) {
00048     emit configurationIconPressed();
00049   }
00050 };
00051 
00052 class SelectionArrowItem : public QObject, public QGraphicsPathItem {
00053 
00054   Q_OBJECT
00055 
00056 public :
00057 
00058   SelectionArrowItem(float initRangePos,const QPoint &initPos);
00059 
00060   bool sceneEvent ( QEvent * event );
00061 
00062 signals :
00063 
00064   void circleMoved();
00065 
00066 protected :
00067 
00068   int yPos;
00069   QPoint initPos;
00070 };
00071 
00072 class SelectionTextItem : public QGraphicsTextItem {
00073 
00074 public :
00075 
00076   SelectionTextItem();
00077 
00078 protected :
00079 
00080   bool sceneEvent ( QEvent * event ) {
00081     return ((SelectionArrowItem*)parentItem())->sceneEvent(event);
00082   }
00083 
00084 };
00085 
00086 class MovableRectItem : public QObject, public QGraphicsRectItem {
00087 
00088   Q_OBJECT
00089 
00090 public :
00091 
00092   MovableRectItem(const QRectF &rect,const QRectF &size,SelectionArrowItem *topCircle, SelectionArrowItem *bottomCircle);
00093 
00094   void setInternalRect(const QRectF &rect);
00095 
00096 signals :
00097 
00098   // begin and end in 0,1 range
00099   void moved(float begin, float end);
00100 
00101 protected :
00102 
00103   bool sceneEvent ( QEvent * event );
00104 
00105   QRectF _currentRect;
00106   QPoint _initPos;
00107   SelectionArrowItem *_topCircle;
00108   SelectionArrowItem *_bottomCircle;
00109 };
00110 
00111 class MovablePathItem : public QObject, public QGraphicsPathItem {
00112 
00113   Q_OBJECT
00114 
00115 public :
00116 
00117   MovablePathItem(const QRectF &rect, QGraphicsPathItem *topPathItem, QGraphicsPathItem *bottomPathItem,SelectionArrowItem *topCircle, SelectionArrowItem *bottomCircle);
00118 
00119   void setDataToPath(const std::vector< std::pair< double,float > > &metricToSizeFilteredList, double minMetric, double maxMetric);
00120 
00121   void setRect(const QRectF &rect);
00122 
00123 signals :
00124 
00125   // begin and end in 0,1 range
00126   void moved(float begin, float end);
00127 
00128 protected :
00129 
00130   void updatePath();
00131 
00132   bool sceneEvent ( QEvent * event );
00133 
00134   std::vector<std::pair <double, float> > _metricToSizeFilteredList;
00135   double _minMetric;
00136   double _maxMetric;
00137 
00138   QRectF _currentRect;
00139   QGraphicsPathItem *_topPathItem;
00140   QGraphicsPathItem *_bottomPathItem;
00141   SelectionArrowItem *_topCircle;
00142   SelectionArrowItem *_bottomCircle;
00143 };
00144 
00145 class CaptionGraphicsBackgroundItem : public QObject, public QGraphicsRectItem {
00146 
00147   Q_OBJECT
00148 
00149 public :
00150 
00151   CaptionGraphicsBackgroundItem(const QRect &rect);
00152 
00153   void generateColorCaption(const QGradient &activeGradient, const QGradient &hideGradient, const std::string &propertyName, double minValue, double maxValue);
00154 
00155   void generateSizeCaption(const std::vector< std::pair< double,float > > &metricToSizeFilteredList, const std::string &propertyName, double minValue, double maxValue);
00156 
00157 public slots :
00158 
00159   void updateCaption();
00160   // begin and end in 0,1 range
00161   void updateCaption(float begin, float end);
00162   void configurationIconPressedSlot();
00163 
00164   void activateInteractions();
00165   void removeInteractions();
00166 
00167 signals :
00168 
00169   void filterChanged(float begin, float end);
00170   void configurationIconPressed();
00171 
00172   void interactionsActivated();
00173   void interactionsRemoved();
00174 
00175 protected :
00176 
00177   void activateInteractions(bool);
00178 
00179   bool sceneEvent ( QEvent * event );
00180   void updateSelectionText(float begin, float end);
00181 
00182   bool _interactionsActivated;
00183   float _beginBackup;
00184   float _endBackup;
00185   QPoint _captionContentPos;
00186 
00187   double _minValue;
00188   double _maxValue;
00189 
00190   // Global Items
00191   QGraphicsTextItem *_minTextItem;
00192   QGraphicsTextItem *_maxTextItem;
00193   QGraphicsTextItem *_min2TextItem;
00194   QGraphicsTextItem *_max2TextItem;
00195   QGraphicsLineItem *_min2LineItem;
00196   QGraphicsLineItem *_max2LineItem;
00197   QGraphicsRectItem *_captionRectBorder;
00198   SelectionArrowItem *_rangeSelector1Item;
00199   SelectionArrowItem *_rangeSelector2Item;
00200   SelectionTextItem *_rangeSelector1TextItem;
00201   SelectionTextItem *_rangeSelector2TextItem;
00202 
00203   // Color caption Items
00204   QGraphicsRectItem *_topCaptionRectItem;
00205   MovableRectItem *_middleCaptionRectItem;
00206   QGraphicsRectItem *_bottomCaptionRectItem;
00207 
00208   // Size caption Items
00209   //MovableRectItem *_selectionSizeRectItem;
00210   MovablePathItem *_sizeCaptionPathItem;
00211   QGraphicsPathItem *_topSizeCaptionPathItem;
00212   QGraphicsPathItem *_bottomSizeCaptionPathItem;
00213 
00214 
00215 };
00216 
00217 }
00218 
00219 #endif // CAPTIONGRAPHICSSUB_H
00220 ///@endcond
 All Classes Files Functions Variables Enumerations Enumerator Properties