Fraxinus  18.10
An IGT application
cxTransferFunctionColorWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 #ifndef CXTRANSFERFUNCTIONCOLORWIDGET_H_
13 #define CXTRANSFERFUNCTIONCOLORWIDGET_H_
14 
15 #include "cxGuiExport.h"
16 
17 #include "cxBaseWidget.h"
18 
19 #include "cxImage.h"
20 #include "cxForwardDeclarations.h"
21 #include "cxActiveImageProxy.h"
22 
23 class QRect;
24 class QMenu;
25 
26 namespace cx
27 {
37 class cxGui_EXPORT TransferFunctionColorWidget : public BaseWidget
38 {
39  Q_OBJECT
40 
41 public:
42  TransferFunctionColorWidget(ActiveDataPtr activeData, QWidget* parent);
43  virtual ~TransferFunctionColorWidget();
44 
45  void setData(ImagePtr image, ImageTFDataPtr tfData);
46 
47 public slots:
48  void activeImageTransferFunctionsChangedSlot();
49 
50 protected slots:
51  void removeColorSlot();
52  void setColorSlot();
53  void setColorSlotDelayed();
54 
55 protected:
56  struct ColorPoint
57  {
58  int intensity;
59  QColor value;
60  ColorPoint() : intensity(-1000000), value(255, 255, 255) {}
61  void reset()
62  {
63  intensity = -1000000;
64  value = QColor(255, 255, 255);
65  }
66  bool isValid()
67  {
68  if(intensity != -1000000)
69  return true;
70  return false;
71  }
72  };
73 
76 
77  QRect mFullArea;
78  QRect mPlotArea;
79  int mBorder;
80 
81  std::map<int, QRect> mPointRects;
83 // int mCurrentClickX, mCurrentClickY;///< The x coordinate currently selected with the mouse
85 
86  ColorPoint selectPoint(QPoint pos) const;
87  std::pair<int,int> findAllowedMoveRangeAroundColorPoint(int selectedPointIntensity);
88  void paintColorPointsAndGenerateCache(QPainter& painter);
89  void paintColorBar(QPainter& painter);
90  void updateTooltip(QPoint pos);
91  void updateTooltip(ColorPoint point);
92 
96 
97  bool isEndpoint(int intensity) const;
98 // bool isInsideCurrentPoint();///< Checks if a screen coordinate is inside any of the point rectangles. Sets mCurrentPoint.position and mCurrentPoint.value
99  void contextMenuEvent(QContextMenuEvent *event);
100 
101 
102  QPoint getPlotPoint(int iScalar);
103  ColorPoint getCurrentColorPoint();
104  ColorPoint getCurrentColorPoint(int clickX);
105 // void moveCurrentPoint();///< Move the currently selected point to the selected screen coordinate (mCurrentClickX)
106  void moveSelectedPointTo(ColorPoint newPoint);
107 
108  virtual void enterEvent(QEvent* event);
109  virtual void leaveEvent(QEvent* event);
110  virtual void mousePressEvent(QMouseEvent* event);
111  virtual void mouseReleaseEvent(QMouseEvent* event);
112  virtual void mouseMoveEvent(QMouseEvent* event);
113  virtual void keyPressEvent(QKeyEvent* event);
114  virtual void resizeEvent(QResizeEvent* evt);
115  virtual void paintEvent(QPaintEvent* event);
116 
117  virtual QSize sizeHint () const { return QSize(100, 30);};
118 
119  int screenX2imageIntensity(int screenX);
120  int imageIntensity2screenX(int intensity);
121 };
122 
123 }
124 #endif /* CXTRANSFERFUNCTIONCOLORWIDGET_H_ */
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:27
boost::shared_ptr< class ActiveImageProxy > ActiveImageProxyPtr
std::map< int, QRect > mPointRects
Cache with all point rectangles.
boost::shared_ptr< class ActiveData > ActiveDataPtr
Definition: cxColorWidget.h:21
QAction * mRemoveColorAction
Action for removing a color.
ColorPoint mSelectedPoint
The currently selected point.
Interface for QWidget which handles widgets uniformly for the system.
Definition: cxBaseWidget.h:88
Internal placeholder for a color point.
boost::shared_ptr< class ImageTFData > ImageTFDataPtr
QAction * mCustomColorAction
Action for choosing custom color.
int mBorder
The size of the border around the transferfunction. The size of the rectangles are mBorder * 2...
Namespace for all CustusX production code.