ddt  0.1
ddtGraphicsView.hpp
Go to the documentation of this file.
1 // @copyright
2 // (c) Copyright ESO 2020
3 // All Rights Reserved
4 // ESO (eso.org) is an Intergovernmental Organization, and therefore special
5 // legal conditions apply.
6 //
7 // @file ddtGraphicsView.hpp
8 // @brief DDT Widgets. Class for the Graphics View which is used by the DDT
9 // Image Widget.
10 //
11 // Class for the Graphics View. The view is used by the Image Widget to actually
12 // display image data and graphical elements.
13 //
14 // @author Carsten Mannel, CGI
15 // @since 2021/08/02
17 
18 #ifndef DATAVISUALISATION_WIDGETSDIALOGS_SRC_INCLUDE_DDT_WIDGETS_DDTGRAPHICSVIEW_HPP_
19 #define DATAVISUALISATION_WIDGETSDIALOGS_SRC_INCLUDE_DDT_WIDGETS_DDTGRAPHICSVIEW_HPP_
20 
21 #include <QtWidgets>
22 
29 #include "ddt/ddtLogger.hpp"
35 #include "ddt/imageHandling.hpp"
36 
39 
40 class DdtImageWidget;
41 
45 typedef struct SlitConfiguration {
49  double config_slit_x;
53  double config_slit_y;
70 
72 
77 class DdtGraphicsView : public QGraphicsView {
78  Q_OBJECT
79 
80  public:
85  explicit DdtGraphicsView(QWidget* parent = nullptr);
86 
90  ~DdtGraphicsView() override;
91 
97  void SetConvertPixelToDegrees(const double convPixelDegrees);
98 
103  void SetDrawMode(const QString mode);
104 
109  void SetDrawSlitLine(const bool drawLine);
110 
118  void SetStatisticRect(const double x1, const double y1, const double x2,
119  const double y2);
120 
125  void SetOverlayImageFile(const QString filename);
126 
132 
137  void AddSlitElementToScene();
138 
144 
150 
154  void UpdateAllStatistics();
155 
159  void UpdateCursorInfo();
160 
161  protected:
166  void mouseMoveEvent(QMouseEvent* event) override;
167 
172  void mousePressEvent(QMouseEvent* event) override;
173 
178  void mouseReleaseEvent(QMouseEvent* event) override;
179 
184  void mouseDoubleClickEvent(QMouseEvent* event) override;
185 
190  void keyPressEvent(QKeyEvent* event) override;
191 
196  void wheelEvent(QWheelEvent* event) override;
197 
204  void drawForeground(QPainter* painter, const QRectF& rect) override;
205 
209  bool isHandleGraphicalElement() const;
210 
215  void AddTextItem();
216 
217  signals:
224  void CursorPosition(double x, double y, bool mouse_clicked);
225 
234  void GraphicalElement(double x1, double y1, double x2, double y2,
235  QString drawMode);
236 
237  void GraphicalTextElement(double x1, double y1, double x2, double y2,
238  QString drawMode, QString text);
239 
240  void StatisticRectangle(double x1, double y1, double x2, double y2);
241 
242  void SlitElement(double target_x, double target_y, double slit_x,
243  double slit_y, double x_offset, double y_offset);
244 
248  void CalculateHistogramReferenceLine(const QPointF p1, const QPointF p2);
249 
253  void CalculateDistanceLine(const QPointF p1, const QPointF p2);
254 
259 
264 
270  void LayerIncrement(const int inc);
271 
277  void LayerDecrement(const int dec);
278 
279  private:
283  DdtImageWidget* parent;
284 
288  bool drawing_enabled = false;
289 
294  QString draw_mode = "none";
295 
300  QPointF orig_point;
301 
306  QPointF cur_point;
307 
311  double convert_pixel_to_degrees = 0.0;
312 
313  DdtGraphicsTextItem* text_item = nullptr;
314  QString current_text = "";
315  QPointF current_text_pos;
316 
317  DdtGraphicalElementStatRectangle* statistic_rect = nullptr;
318  DdtGraphicalElementSlit* slit_element = nullptr;
319  DdtGraphicalElementRefLine* ref_line_element = nullptr;
320  DdtGraphicalElementRefLine* dist_line_element = nullptr;
321  bool draw_slit_line = false;
322  bool slit_config_read = false;
323 
324  // Configurable properties of slit overlay
325  SlitConfiguration slit_config;
326 
327  QString overlay_image_file;
328 
329  std::unique_ptr<DdtGraphicsViewDraw> graphicsViewDraw =
330  std::unique_ptr<DdtGraphicsViewDraw>(new DdtGraphicsViewDraw());
331 
338  void DrawSlit(QPainter& painter, const QPointF start);
339 
344  void ReadSlitParameter(const std::string config_file, double* const slit_x,
345  double* const slit_y, double* const slit_size_x,
346  double* const slit_size_y, double* const slit_angle,
347  QString* const slit_color) const;
351  void CreateSlit(const QColor line_color, const double slit_x,
352  const double slit_y, const double slit_size_x,
353  const double slit_size_y, const double slit_angle);
354 
358  std::string GetConfigPath() const;
359 };
360 
361 #endif /* DATAVISUALISATION_WIDGETSDIALOGS_SRC_INCLUDE_DDT_WIDGETS_DDTGRAPHICSVIEW_HPP_ \
362  */
DdtGraphicsView::isHandleGraphicalElement
bool isHandleGraphicalElement() const
Definition: ddtGraphicsView.cpp:370
DdtGraphicsView::AddTextItem
void AddTextItem()
Definition: ddtGraphicsView.cpp:485
DdtGraphicsView::LayerIncrement
void LayerIncrement(const int inc)
DdtGraphicalElementStatRectangle
Definition: ddtGraphicalElementStatRectangle.hpp:25
DdtGraphicalElementSlit
Definition: ddtGraphicalElementSlit.hpp:24
DdtGraphicsView::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *event) override
Definition: ddtGraphicsView.cpp:284
DdtGraphicsView::MouseIncrementScale
void MouseIncrementScale()
ddtGraphicalElementStatRectangle.hpp
DdtGraphicalElementRefLine
Definition: ddtGraphicalElementRefLine.hpp:25
SlitConfiguration::config_slit_size_y
double config_slit_size_y
Definition: ddtGraphicsView.hpp:61
DdtGraphicsView::keyPressEvent
void keyPressEvent(QKeyEvent *event) override
Definition: ddtGraphicsView.cpp:382
DdtGraphicsView::GraphicalElement
void GraphicalElement(double x1, double y1, double x2, double y2, QString drawMode)
DdtGraphicsView::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *event) override
Definition: ddtGraphicsView.cpp:197
SlitConfiguration
Definition: ddtGraphicsView.hpp:45
DdtGraphicsView::DdtGraphicsView
DdtGraphicsView(QWidget *parent=nullptr)
Definition: ddtGraphicsView.cpp:31
DdtGraphicsViewDraw
Definition: ddtGraphicsViewDraw.hpp:33
ddtDialogFactory.hpp
SlitConfiguration::config_slit_x
double config_slit_x
Definition: ddtGraphicsView.hpp:49
DdtGraphicsView::mouseDoubleClickEvent
void mouseDoubleClickEvent(QMouseEvent *event) override
Definition: ddtGraphicsView.cpp:441
DdtGraphicsView::LayerDecrement
void LayerDecrement(const int dec)
ddtGraphicalElementProperties.hpp
ddtDialog.hpp
DdtGraphicsView::SetDrawMode
void SetDrawMode(const QString mode)
Definition: ddtGraphicsView.cpp:46
DdtGraphicsView::UpdateCursorInfo
void UpdateCursorInfo()
Definition: ddtGraphicsView.cpp:190
DdtGraphicsView::SetConvertPixelToDegrees
void SetConvertPixelToDegrees(const double convPixelDegrees)
Definition: ddtGraphicsView.cpp:36
DdtGraphicsView::AddDistanceLineElementToScene
void AddDistanceLineElementToScene()
Definition: ddtGraphicsView.cpp:146
DdtGraphicsView::SlitElement
void SlitElement(double target_x, double target_y, double slit_x, double slit_y, double x_offset, double y_offset)
ddtGraphicsViewDraw.hpp
DdtGraphicsView::CalculateDistanceLine
void CalculateDistanceLine(const QPointF p1, const QPointF p2)
ddtGraphicalElementSlit.hpp
SlitConfiguration::config_slit_angle
double config_slit_angle
Definition: ddtGraphicsView.hpp:65
DdtGraphicsView::UpdateAllStatistics
void UpdateAllStatistics()
Definition: ddtGraphicsView.cpp:155
DdtGraphicsView::~DdtGraphicsView
~DdtGraphicsView() override
DdtGraphicsView::SetOverlayImageFile
void SetOverlayImageFile(const QString filename)
Definition: ddtGraphicsView.cpp:114
SlitConfiguration::config_slit_color
QString config_slit_color
Definition: ddtGraphicsView.hpp:69
DdtGraphicsView::CursorPosition
void CursorPosition(double x, double y, bool mouse_clicked)
SlitConfiguration::config_slit_size_x
double config_slit_size_x
Definition: ddtGraphicsView.hpp:57
ddtGraphicsTextItem.hpp
ddtDialogIds.hpp
DdtGraphicsView::StatisticRectangle
void StatisticRectangle(double x1, double y1, double x2, double y2)
DdtImageWidget
Definition: ddtImageWidget.hpp:46
DdtGraphicsView::SetStatisticRect
void SetStatisticRect(const double x1, const double y1, const double x2, const double y2)
Definition: ddtGraphicsView.cpp:96
DdtGraphicsView::GraphicalTextElement
void GraphicalTextElement(double x1, double y1, double x2, double y2, QString drawMode, QString text)
DdtGraphicsView::mousePressEvent
void mousePressEvent(QMouseEvent *event) override
Definition: ddtGraphicsView.cpp:216
SlitConfiguration::config_slit_y
double config_slit_y
Definition: ddtGraphicsView.hpp:53
ddtOverlayRendering.hpp
DdtGraphicsView::SetDrawSlitLine
void SetDrawSlitLine(const bool drawLine)
Definition: ddtGraphicsView.cpp:91
ddtGraphicalElementImage.hpp
DdtGraphicsView::AddStatisticRectToScene
void AddStatisticRectToScene()
Definition: ddtGraphicsView.cpp:120
ddtRenderingPlugin.hpp
DdtGraphicsView::AddReferenceLineElementToScene
void AddReferenceLineElementToScene()
Definition: ddtGraphicsView.cpp:137
DdtGraphicsView::wheelEvent
void wheelEvent(QWheelEvent *event) override
Definition: ddtGraphicsView.cpp:446
ddtLogger.hpp
DdtGraphicsView::CalculateHistogramReferenceLine
void CalculateHistogramReferenceLine(const QPointF p1, const QPointF p2)
ddtGraphicalElementRefLine.hpp
SlitConfiguration
struct SlitConfiguration SlitConfiguration
ddtImageWidget.hpp
DdtGraphicsView
Definition: ddtGraphicsView.hpp:77
DdtGraphicsView::drawForeground
void drawForeground(QPainter *painter, const QRectF &rect) override
Definition: ddtGraphicsView.cpp:457
imageHandling.hpp
DdtGraphicsTextItem
Definition: ddtGraphicsTextItem.hpp:23
DdtGraphicsView::AddSlitElementToScene
void AddSlitElementToScene()
Definition: ddtGraphicsView.cpp:130
DdtGraphicsView::MouseDecrementScale
void MouseDecrementScale()