MCPcopy Create free account
hub / github.com/cpvrlab/ImagePlay / on_mousePositionChanged

Method on_mousePositionChanged

ImagePlay/src/ImageViewerWindow.cpp:840–930  ·  view source on GitHub ↗

----------------------------------------------------------------------------- ! ImageViewerWindow::on_mousePositionChanged Updates the position of the zoomWindow and the pixel information window */

Source from the content-addressed store, hash-verified

838Updates the position of the zoomWindow and the pixel information window
839*/
840void ImageViewerWindow::on_mousePositionChanged(int x, int y)
841{
842 // check if we have a valid image
843 if(!((IPImageViewer*) ui->tabWidget->currentWidget())->image())
844 return;
845
846 if(x < 0 || y < 0)
847 return;
848
849 if(_ignoreMouseEvents)
850 return;
851
852 if(ui->zoomWidget->isPositionLocked())
853 return;
854
855 // save current color and position for later usage by pickhandlers
856 _currentColor = QColor(((IPImageViewer*) ui->tabWidget->currentWidget())->image()->pixel(x, y));
857 _currentPosition = QPoint(x,y);
858
859 IPLData* data = NULL;
860 if(((IPImageViewer*) ui->tabWidget->currentWidget())->rawData())
861 {
862 data = ((IPImageViewer*) ui->tabWidget->currentWidget())->rawData();
863 if(!data)
864 return;
865 }
866
867 QString message("<table><tr>");
868 message.append("<td><b>Position: </b></td>");
869 message.append("<td>x: %1, y: %2</td>");
870 message.append("</tr><tr>");
871 message.append("<td><b>Center Value: </b></td>");
872 message.append("<td>%3</td>");
873 message.append("</tr></table>");
874
875
876 QString value;
877 if(data->type() == IPL_IMAGE_COLOR)
878 {
879 IPLImage* image = data->toImage();
880 QString r = QString::number(image->plane(0)->cp(x, y), 'f', 2);
881 QString g = QString::number(image->plane(1)->cp(x, y), 'f', 2);
882 QString b = QString::number(image->plane(2)->cp(x, y), 'f', 2);
883 value.append("<table width=\"120\"><tr>");
884 value.append("<td align=\"right\" style=\"color:#FF0000;\">%1</td>");
885 value.append("<td align=\"right\" style=\"color:#41DB00;\">%2</td>");
886 value.append("<td align=\"right\" style=\"color:#0094FF;\">%3</td>");
887 value.append("</tr></table>");
888
889 value = value.arg(r).arg(g).arg(b);
890 }
891 else if(data->type() == IPL_IMAGE_GRAYSCALE || data->type() == IPL_IMAGE_BW)
892 {
893 IPLImage* image = data->toImage();
894 QString v = QString::number(image->plane(0)->cp(x, y), 'f', 2);
895 value.append("<span>%1</span>");
896
897 value = value.arg(v);

Callers

nothing calls this directly

Calls 12

imageMethod · 0.80
isPositionLockedMethod · 0.80
rawDataMethod · 0.80
toImageMethod · 0.80
planeMethod · 0.80
toComplexImageMethod · 0.80
widthMethod · 0.80
heightMethod · 0.80
realMethod · 0.80
imagMethod · 0.80
setPositionMethod · 0.80
typeMethod · 0.45

Tested by

no test coverage detected