CycloBranch
cImageWindowWidget.h
Go to the documentation of this file.
1
7#ifndef _CIMAGEWINDOWWIDGET_H
8#define _CIMAGEWINDOWWIDGET_H
9
10#include <QWidget>
11#include <QGraphicsView>
12#include <QPixmap>
13#include <QImage>
14#include <unordered_set>
15#include "core/utilities.h"
16
17
21const int numberoflayers = 204;
22
23
28 cursoractivity_none = 0,
29 cursoractivity_move,
30 cursoractivity_resize_left,
31 cursoractivity_resize_right,
32 cursoractivity_resize_top,
33 cursoractivity_resize_bottom,
34 cursoractivity_resize_top_left,
35 cursoractivity_resize_top_right,
36 cursoractivity_resize_bottom_left,
37 cursoractivity_resize_bottom_right
38};
39
40
44struct layerInfo {
48 bool checked;
49
50
54 int alpha;
55
56
60 int zvalue;
61
62
67
68
73
74
79
80
84 double x;
85
86
90 double y;
91
92
96 double width;
97
98
102 double height;
103
104
108 double angle;
109
110
114 qreal lastx;
115
116
120 qreal lasty;
121
122
127
128
132 QPixmap* pixmap;
133
134
139 pixmap = new QPixmap();
140 clear();
141 }
142
143
147 layerInfo(const layerInfo& layer) {
148 checked = layer.checked;
149 alpha = layer.alpha;
150 zvalue = layer.zvalue;
154 x = layer.x;
155 y = layer.y;
156 width = layer.width;
157 height = layer.height;
158 angle = layer.angle;
159 lastx = layer.lastx;
160 lasty = layer.lasty;
162 pixmap = new QPixmap();
163 *pixmap = *layer.pixmap;
164 }
165
166
170 void clear() {
171 checked = true;
172 alpha = 100;
173 zvalue = 0;
174 ispixmapdefined = false;
175 fliphorizontally = false;
176 flipvertically = false;
177 x = 0;
178 y = 0;
179 width = 0;
180 height = 0;
181 angle = 0;
182 lastx = 0;
183 lasty = 0;
184 navigationlayer = 3;
185
186 delete pixmap;
187 pixmap = new QPixmap();
188 }
189
190
195 delete pixmap;
196 }
197};
198
199
200
204class cImageWindowWidget : public QGraphicsView
205{
206 Q_OBJECT
207
208public:
209
210
215
216
221
222
227 void setOpticalImage(QImage* image);
228
229
234 void setHistologyImage(QImage* histologyimage);
235
236
242 void setMicroscopyImage(int layer, QImage* microscopyimage);
243
244
249 QImage getImage();
250
251
265 void setFilterOptions(vector<cCoordinateInfo>& coordinateinfo, bool operatortype, string& columnname1, string& comparatorname1, string& filterstring1, string& columnname2, string& comparatorname2, string& filterstring2, bool casesensitive, bool wholeword);
266
267
277 void setCorrelationValues(int leftshift, int topshift, int maxx, int maxy, int pixelsizex, int pixelsizey);
278
279
288 void setDefaultMaxXY(int defaultmaxx, int defaultmaxy, int defaultpixelsizex, int defaultpixelsizey, eVendorType vendor);
289
290
299 void setHistologyPosition(int x, int y, int width, int height, double angle);
300
301
313 void setMicroscopyPosition(int layer, bool flipx, bool flipy, double x, double y, double width, double height, double angle);
314
315
320 void goToMicroscopyPosition(int layer);
321
322
330 void setSelectedRegion(int xfrom, int xto, int yfrom, int yto);
331
332
336 void redraw();
337
338
342 void clearLayers();
343
344
348 void clearLayer(int layer);
349
350
355 void setKeepAspectRatio(bool state);
356
357
363 void setNavigationLayer(int layer, int navigation);
364
365
366protected:
367
368
373 void wheelEvent(QWheelEvent *event);
374
375
380 void mousePressEvent(QMouseEvent *event);
381
382
387 void mouseMoveEvent(QMouseEvent *event);
388
389
394 void mouseReleaseEvent(QMouseEvent *event);
395
396
401 void mouseDoubleClickEvent(QMouseEvent *event);
402
403
408 void resizeEvent(QResizeEvent *event);
409
410
411signals:
412
413
421 void updateFilter(int xmin, int xmax, int ymin, int ymax);
422
423
431 void updateCorrelation(int xmin, int xmax, int ymin, int ymax);
432
433
442 void updateHistologyPosition(int x, int y, int width, int height, double angle);
443
444
455 void updateMicroscopyPosition(bool flipx, bool flipy, double x, double y, double width, double height, double angle);
456
457
462 void updateRuler(double size);
463
464
469 void imageWidgetDoubleClicked(int spectrumid);
470
471
472private:
473
474 QWidget* parent;
475 QGraphicsScene* scene;
476
477 vector<cCoordinateInfo> coordinateinfo;
478 bool operatortype;
479 string columnname1;
480 string comparatorname1;
481 string filterstring1;
482 string columnname2;
483 string comparatorname2;
484 string filterstring2;
485 bool casesensitive;
486 bool wholeword;
487
488 bool colorscale;
489 bool absoluteintensity;
490
491 vector<layerInfo> layersvector;
492 int activelayer;
493
494 int xfrom;
495 int xto;
496 int yfrom;
497 int yto;
498
499 int leftshift;
500 int topshift;
501 int maxx;
502 int maxy;
503 int pixelsizex;
504 int pixelsizey;
505
506 int defaultmaxx;
507 int defaultmaxy;
508 int defaultpixelsizex;
509 int defaultpixelsizey;
510 eVendorType vendor;
511
512 qreal currentscale;
513 qreal factor;
514
515 int rulersize;
516 double rulervalue;
517
518 int pressedx;
519 int pressedy;
520 int currentx;
521 int currenty;
522 int currentwidth;
523 int currentheight;
524
525 bool showselection;
526 bool keepaspectratio;
527
528 qreal microscopynavigationcenterx;
529 qreal microscopynavigationcentery;
530
531 QGraphicsRectItem* selectionrect;
532 QGraphicsSimpleTextItem* selectionsimpletextitem;
533
534 QGraphicsRectItem* currentrect;
535 eCursorActivityType cursoractivity;
536
537 void redrawScene();
538
539 void drawMicroscopyImage(int layer, QRectF& rect_scene, int currentwidth, int currentheight);
540
541 void updateSelectionGroup();
542
543 void getRectanglePoints(qreal& rx1, qreal& ry1, qreal& rx2, qreal& ry2);
544
545 double prepareTransformation(QRectF rect, QTransform& transform, bool testedfliphorizontally, bool testedflipvertically, double testedangle, bool flipaxes);
546
547 void fixRectCenter(qreal& rx1, qreal& ry1, qreal& rx2, qreal& ry2, bool testedfliphorizontally, bool testedflipvertically, double testedangle);
548
549 double recalculateRulerValue(qreal currentscale);
550
551
552private slots:
553
554
555 void zoomIn();
556
557
558 void zoomOut();
559
560
561 void normalSize();
562
563
564 void setRulerValue(double value);
565
566
567 void scrollbarValueChanged(int value);
568
569
570 void absoluteIntensityStateChanged(bool state);
571
572
573 void colorScaleStateChanged(bool state);
574
575
576 void changeLayer(int layerid, bool checked, int alpha, int zvalue, bool redraw);
577
578
579 void changeActiveLayer(int layerid);
580
581
582 void flipHistologyHorizontallyStateChanged(bool state);
583
584
585 void flipHistologyVerticallyStateChanged(bool state);
586
587
588 void showSelectionStateChanged(bool state);
589
590};
591
592#endif
const int numberoflayers
The number of layers.
Definition: cImageWindowWidget.h:21
eCursorActivityType
Cursor activity.
Definition: cImageWindowWidget.h:27
Image window widget.
Definition: cImageWindowWidget.h:205
void redraw()
Redraw widget.
Definition: cImageWindowWidget.cpp:219
void setHistologyPosition(int x, int y, int width, int height, double angle)
Set the position of a histology image.
Definition: cImageWindowWidget.cpp:181
void updateMicroscopyPosition(bool flipx, bool flipy, double x, double y, double width, double height, double angle)
The signal is emitted when the microscopy position was changed.
void imageWidgetDoubleClicked(int spectrumid)
The image was double clicked.
void mousePressEvent(QMouseEvent *event)
Handle the mouse press event.
Definition: cImageWindowWidget.cpp:269
void goToMicroscopyPosition(int layer)
Go to the position of a microscopy image.
Definition: cImageWindowWidget.cpp:201
void mouseDoubleClickEvent(QMouseEvent *event)
Handle the mouse double click event.
Definition: cImageWindowWidget.cpp:608
void updateFilter(int xmin, int xmax, int ymin, int ymax)
The signal is emitted when the selection of points was changed.
void setSelectedRegion(int xfrom, int xto, int yfrom, int yto)
Set the current region.
Definition: cImageWindowWidget.cpp:211
void setKeepAspectRatio(bool state)
Set the flag to keep aspect ratio.
Definition: cImageWindowWidget.cpp:240
~cImageWindowWidget()
The destructor.
Definition: cImageWindowWidget.cpp:89
QImage getImage()
Get the image.
Definition: cImageWindowWidget.cpp:122
void updateHistologyPosition(int x, int y, int width, int height, double angle)
The signal is emitted when the histology position was changed.
void resizeEvent(QResizeEvent *event)
Handle the resize event.
Definition: cImageWindowWidget.cpp:658
void wheelEvent(QWheelEvent *event)
Handle the mouse wheel event.
Definition: cImageWindowWidget.cpp:257
cImageWindowWidget()
The constructor.
Definition: cImageWindowWidget.cpp:9
void clearLayers()
Clear the vector of layers.
Definition: cImageWindowWidget.cpp:224
void clearLayer(int layer)
Clear a layer.
Definition: cImageWindowWidget.cpp:233
void setMicroscopyPosition(int layer, bool flipx, bool flipy, double x, double y, double width, double height, double angle)
Set the position of a microscopy image.
Definition: cImageWindowWidget.cpp:190
void updateCorrelation(int xmin, int xmax, int ymin, int ymax)
The signal is emitted when the points area in the optical image was changed.
void updateRuler(double size)
The signal is emitted when the ruler size was changed.
void setHistologyImage(QImage *histologyimage)
Set the histology image.
Definition: cImageWindowWidget.cpp:108
void setMicroscopyImage(int layer, QImage *microscopyimage)
Set the microscopy image.
Definition: cImageWindowWidget.cpp:115
void setCorrelationValues(int leftshift, int topshift, int maxx, int maxy, int pixelsizex, int pixelsizey)
Set the values to corelate data with optical image.
Definition: cImageWindowWidget.cpp:160
void setDefaultMaxXY(int defaultmaxx, int defaultmaxy, int defaultpixelsizex, int defaultpixelsizey, eVendorType vendor)
Set the default maximum X and Y coordinates - parsed from the imzML file.
Definition: cImageWindowWidget.cpp:172
void setNavigationLayer(int layer, int navigation)
Set navigation layer.
Definition: cImageWindowWidget.cpp:252
void mouseMoveEvent(QMouseEvent *event)
Handle the mouse move event.
Definition: cImageWindowWidget.cpp:413
void setFilterOptions(vector< cCoordinateInfo > &coordinateinfo, bool operatortype, string &columnname1, string &comparatorname1, string &filterstring1, string &columnname2, string &comparatorname2, string &filterstring2, bool casesensitive, bool wholeword)
Set options which was used to filter the points.
Definition: cImageWindowWidget.cpp:145
void mouseReleaseEvent(QMouseEvent *event)
Handle the mouse release event.
Definition: cImageWindowWidget.cpp:430
void setOpticalImage(QImage *image)
Set the optical image.
Definition: cImageWindowWidget.cpp:95
Paramaters of a layer.
Definition: cImageWindowWidget.h:44
int alpha
Opacity of the layer.
Definition: cImageWindowWidget.h:54
double height
Height.
Definition: cImageWindowWidget.h:102
qreal lastx
Last X position.
Definition: cImageWindowWidget.h:114
layerInfo()
The constructor.
Definition: cImageWindowWidget.h:138
double angle
Rotation angle [degrees].
Definition: cImageWindowWidget.h:108
QPixmap * pixmap
Pixmap.
Definition: cImageWindowWidget.h:132
int zvalue
Z-value of the layer.
Definition: cImageWindowWidget.h:60
~layerInfo()
The destructor.
Definition: cImageWindowWidget.h:194
bool flipvertically
True if the pixmap is flipped vertically.
Definition: cImageWindowWidget.h:78
double x
X position.
Definition: cImageWindowWidget.h:84
bool fliphorizontally
True if the pixmap is flipped horizontally.
Definition: cImageWindowWidget.h:72
int navigationlayer
Navigation layer.
Definition: cImageWindowWidget.h:126
bool ispixmapdefined
True if pixmap is defined.
Definition: cImageWindowWidget.h:66
double width
Width.
Definition: cImageWindowWidget.h:96
bool checked
True if the layer is visible.
Definition: cImageWindowWidget.h:48
void clear()
Clear the structure.
Definition: cImageWindowWidget.h:170
double y
Y position.
Definition: cImageWindowWidget.h:90
qreal lasty
Last Y position.
Definition: cImageWindowWidget.h:120
layerInfo(const layerInfo &layer)
The copy constructor.
Definition: cImageWindowWidget.h:147
Auxiliary funtions and structures.
eVendorType
Vendor types.
Definition: utilities.h:82