@@ -94,7 +94,6 @@ void CreateStandardColorMapDialog::pullSpecial()
9494 }
9595 else
9696 {
97- previewColorMap_->addEndpoints ();
9897 for (const auto & p : pointsVec)
9998 {
10099 auto pVec = p.toVector ();
@@ -189,7 +188,6 @@ void ColormapPreview::mousePressEvent(QMouseEvent* event)
189188 }
190189
191190 // TODO: remove point if event & RightMouseButton
192-
193191 // TODO: points are movable!
194192}
195193
@@ -201,13 +199,6 @@ void ColormapPreview::addDefaultLine()
201199 alphaPath_ = scene ()->addLine (defaultStart_.x (), defaultStart_.y (),
202200 defaultEnd_.x (), defaultEnd_.y (),
203201 alphaLinePen);
204- alphaManager_.insertEndpoints ();
205- }
206-
207- void AlphaFunctionManager::insertEndpoints ()
208- {
209- alphaPoints_.insert (defaultStart_);
210- insert (defaultEnd_); // only update function and state after both endpoints are added
211202}
212203
213204void ColormapPreview::removeDefaultLine ()
@@ -218,18 +209,13 @@ void ColormapPreview::removeDefaultLine()
218209
219210void ColormapPreview::addPoint (const QPointF& point)
220211{
221- if (alphaManager_.alreadyExists (point))
222- return ;
212+ if (alphaManager_.alreadyExists (point)) return ;
223213
224214 removeDefaultLine ();
225215
226216 static QPen pointPen (Qt::white, 1 );
227217 auto item = scene ()->addEllipse (point.x () - 4 , point.y () - 4 , 8 , 8 , pointPen, QBrush (Qt::black));
228218 item->setZValue (1 );
229- // QString toolTip;
230- // QDebug tt(&toolTip);
231- // tt << "Alpha point " << point.x() << ", " << point.y() << " y% " << (1 - point.y() / sceneRect().height());
232- // item->setToolTip(toolTip);
233219 alphaManager_.insert (point);
234220
235221 drawAlphaPolyline ();
@@ -264,8 +250,6 @@ void AlphaFunctionManager::pushToState()
264250 Variable::List alphaPointsVec;
265251 // strip endpoints before saving user-added points
266252 auto begin = alphaPoints_.begin (), end = alphaPoints_.end ();
267- std::advance (begin, 1 );
268- std::advance (end, -1 );
269253 std::for_each (begin, end, [&](const QPointF& p) { alphaPointsVec.emplace_back (Name (" alphaPoint" ), makeAnonymousVariableList (p.x (), p.y ())); });
270254 state_->setValue (Parameters::AlphaUserPointsVector, alphaPointsVec);
271255 }
@@ -284,15 +268,16 @@ void ColormapPreview::drawAlphaPolyline()
284268 auto pathItem = new QGraphicsPathItem ();
285269 alphaPath_ = pathItem;
286270 pathItem->setPen (alphaLinePen);
271+
287272 QPainterPath path;
288- QPointF from = defaultStart_;
289- path.moveTo (from);
273+ auto start = alphaManager_.begin ();
274+ auto end = alphaManager_.end (); std::advance (end, -1 );
275+ QPointF from = QPointF (defaultStart_.x (), start->y ());
276+ QPointF to = QPointF (defaultEnd_.x (), end->y ());
290277
291- for (const auto & point : alphaManager_)
292- {
293- path.lineTo (point);
294- path.moveTo (point);
295- }
278+ path.moveTo (from);
279+ for (const auto & point : alphaManager_) path.lineTo (point);
280+ path.lineTo (to);
296281
297282 pathItem->setPath (path);
298283 pathItem->setZValue (0 );
@@ -317,12 +302,11 @@ void AlphaFunctionManager::updateAlphaFunction()
317302
318303 for (int i = 0 ; i < static_cast <int >(alphaFunction_.size ()); ++i)
319304 {
320- if (i > 0 && i < alphaFunction_.size () - 1 )
305+ if (false && i > 0 && i < alphaFunction_.size () - 1 )
321306 {
322307 double color = i / static_cast <double >(ALPHA_SAMPLES + 1 );
323308 auto between = alphaLineEndpointsAtColor (color);
324309 alphaFunction_[i] = interpolateAlphaLineValue (between.first , between.second , color);
325- // qDebug() << "Color: " << color << "Alpha: " << alphaFunction_[i] << "between points" << between.first << between.second;
326310 }
327311 else
328312 {
@@ -353,7 +337,7 @@ double AlphaFunctionManager::interpolateAlphaLineValue(const QPointF& leftEndpoi
353337
354338double AlphaFunctionManager::pointYToAlpha (double y) const
355339{
356- return 1 - y / colorMapPreviewRect.height ();
340+ return 1 . 0f - y / colorMapPreviewRect.height ();
357341}
358342
359343QPointF AlphaFunctionManager::colorToPoint (double color) const
0 commit comments