MCPcopy Create free account
hub / github.com/KDE/labplot / itemChange

Method itemChange

src/backend/datapicker/Segment.cpp:141–184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139}
140
141QVariant SegmentPrivate::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant& value) {
142 if (change == QGraphicsItem::ItemSelectedChange && value == true) {
143 auto* datapicker = static_cast<Datapicker*>(q->m_image->parentAspect());
144 if (datapicker->activeCurve()) {
145 int count = 0;
146 QList<QPointF> posList;
147 posList.clear();
148 for (QLine* line : q->path) {
149 const int l = (line->y1() > line->y2()) ? line->y2() : line->y1();
150 const int h = (line->y1() > line->y2()) ? line->y1() : line->y2();
151
152 for (int i = l; i <= h; ++i) {
153 if (count % q->m_image->pointSeparation() == 0) {
154 bool positionUsed = false;
155 const auto points = datapicker->activeCurve()->children<DatapickerPoint>(AbstractAspect::ChildIndexFlag::IncludeHidden);
156 for (const auto* point : points) {
157 if (point->position() == QPoint(line->x1(), i) * scaleFactor)
158 positionUsed = true;
159 }
160
161 if (!positionUsed)
162 posList << QPoint(line->x1(), i) * scaleFactor;
163 }
164 count++;
165 }
166 }
167
168 if (!posList.isEmpty()) {
169 auto* curve = datapicker->activeCurve();
170 curve->beginMacro(i18n("%1: draw points over segment", datapicker->activeCurve()->name()));
171 curve->suppressUpdatePoint(true);
172 for (const QPointF& pos : posList)
173 datapicker->addNewPoint(pos, curve);
174 curve->suppressUpdatePoint(false);
175 curve->endMacro();
176 }
177 }
178
179 // no need to keep segment selected
180 return false;
181 }
182
183 return QGraphicsItem::itemChange(change, value);
184}

Callers

nothing calls this directly

Calls 10

parentAspectMethod · 0.80
activeCurveMethod · 0.80
positionMethod · 0.80
beginMacroMethod · 0.80
suppressUpdatePointMethod · 0.80
addNewPointMethod · 0.80
endMacroMethod · 0.80
clearMethod · 0.45
isEmptyMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected