comparison Framework/Radiography/RadiographyLayerCropTracker.cpp @ 476:a95090305dd4 am-touch-events

Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
author am@osimis.io
date Wed, 13 Feb 2019 12:04:02 +0100
parents 3b4df9925db6
children 4f2416d519b4
comparison
equal deleted inserted replaced
475:3c28542229a3 476:a95090305dd4
66 66
67 RadiographyLayerCropTracker::RadiographyLayerCropTracker(UndoRedoStack& undoRedoStack, 67 RadiographyLayerCropTracker::RadiographyLayerCropTracker(UndoRedoStack& undoRedoStack,
68 RadiographyScene& scene, 68 RadiographyScene& scene,
69 const ViewportGeometry& view, 69 const ViewportGeometry& view,
70 size_t layer, 70 size_t layer,
71 double x, 71 const ControlPoint& startControlPoint) :
72 double y,
73 Corner corner) :
74 undoRedoStack_(undoRedoStack), 72 undoRedoStack_(undoRedoStack),
75 accessor_(scene, layer), 73 accessor_(scene, layer),
76 corner_(corner) 74 startControlPoint_(startControlPoint)
77 { 75 {
78 if (accessor_.IsValid()) 76 if (accessor_.IsValid())
79 { 77 {
80 accessor_.GetLayer().GetCrop(cropX_, cropY_, cropWidth_, cropHeight_); 78 accessor_.GetLayer().GetCrop(cropX_, cropY_, cropWidth_, cropHeight_);
81 } 79 }
112 RadiographyLayer& layer = accessor_.GetLayer(); 110 RadiographyLayer& layer = accessor_.GetLayer();
113 if (layer.GetPixel(x, y, sceneX, sceneY)) 111 if (layer.GetPixel(x, y, sceneX, sceneY))
114 { 112 {
115 unsigned int targetX, targetWidth; 113 unsigned int targetX, targetWidth;
116 114
117 if (corner_ == Corner_TopLeft || 115 if (startControlPoint_.index == ControlPoint_TopLeftCorner ||
118 corner_ == Corner_BottomLeft) 116 startControlPoint_.index == ControlPoint_BottomLeftCorner)
119 { 117 {
120 targetX = std::min(x, cropX_ + cropWidth_); 118 targetX = std::min(x, cropX_ + cropWidth_);
121 targetWidth = cropX_ + cropWidth_ - targetX; 119 targetWidth = cropX_ + cropWidth_ - targetX;
122 } 120 }
123 else 121 else
126 targetWidth = std::max(x, cropX_) - cropX_; 124 targetWidth = std::max(x, cropX_) - cropX_;
127 } 125 }
128 126
129 unsigned int targetY, targetHeight; 127 unsigned int targetY, targetHeight;
130 128
131 if (corner_ == Corner_TopLeft || 129 if (startControlPoint_.index == ControlPoint_TopLeftCorner ||
132 corner_ == Corner_TopRight) 130 startControlPoint_.index == ControlPoint_TopRightCorner)
133 { 131 {
134 targetY = std::min(y, cropY_ + cropHeight_); 132 targetY = std::min(y, cropY_ + cropHeight_);
135 targetHeight = cropY_ + cropHeight_ - targetY; 133 targetHeight = cropY_ + cropHeight_ - targetY;
136 } 134 }
137 else 135 else