MCPcopy Create free account
hub / github.com/computationalpathologygroup/ASAP / addCoordinate

Method addCoordinate

ASAP/annotation/RectangleAnnotationTool.cpp:173–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

171}
172
173void RectangleAnnotationTool::addCoordinate(const QPointF& scenePos) {
174 if (_annotationPlugin->getGeneratedAnnotation()->getAnnotation()->getCoordinates().size() > 0) {
175 _annotationPlugin->getGeneratedAnnotation()->getAnnotation()->clearCoordinates();
176 float width = std::abs(2 * (scenePos.x() - _start.getX()) / _viewer->getSceneScale());
177 float height = std::abs(2 * (scenePos.y() - _start.getY()) / _viewer->getSceneScale());
178 float left = (_start.getX() / _viewer->getSceneScale()) - width / 2.;
179 float top = (_start.getY() / _viewer->getSceneScale()) - height / 2.;
180 _annotationPlugin->getGeneratedAnnotation()->getAnnotation()->addCoordinate(left, top);
181 _annotationPlugin->getGeneratedAnnotation()->getAnnotation()->addCoordinate(left + width, top);
182 _annotationPlugin->getGeneratedAnnotation()->getAnnotation()->addCoordinate(left + width, top + height);
183 _annotationPlugin->getGeneratedAnnotation()->getAnnotation()->addCoordinate(left, top + height);
184 _annotationPlugin->getGeneratedAnnotation()->setPos(QPointF(left * _viewer->getSceneScale(), top * _viewer->getSceneScale()));
185 _annotationPlugin->finishAnnotation();
186 if (_activeRect) {
187 _viewer->scene()->removeItem(_activeRect);
188 delete _activeRect;
189 _activeRect = NULL;
190 }
191 if (_sizeText) {
192 _viewer->scene()->removeItem(_sizeText);
193 delete _sizeText;
194 _sizeText = NULL;
195 }
196 _start = Point(-1, -1);
197 _last = _start;
198 _generating = false;
199 }
200 else {
201 _annotationPlugin->getGeneratedAnnotation()->addCoordinate(scenePos.x() / _viewer->getSceneScale(), scenePos.y() / _viewer->getSceneScale());
202 _last = Point(scenePos.x(), scenePos.y());
203 }
204}
205
206QAction* RectangleAnnotationTool::getToolButton() {
207 if (!_button) {

Callers 1

mouseDoubleClickEventMethod · 0.95

Calls 7

PointClass · 0.85
sizeMethod · 0.80
getCoordinatesMethod · 0.80
clearCoordinatesMethod · 0.80
finishAnnotationMethod · 0.80
getAnnotationMethod · 0.45

Tested by

no test coverage detected