Skip to content

Commit 31d88ec

Browse files
author
Haydelj
committed
ui fixed
1 parent f197fd4 commit 31d88ec

File tree

4 files changed

+14
-37
lines changed

4 files changed

+14
-37
lines changed

src/Core/Datatypes/ColorMap.cc

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,16 +207,12 @@ ColorRGB ColorMap::applyAlpha(double transformed, ColorRGB colorWithoutAlpha) co
207207

208208
double ColorMap::alpha(double transformedValue) const
209209
{
210-
transformedValue *= 364.0;
210+
transformedValue *= 365.0f;
211211
if(alphaLookup_.size() == 0) return 0.5;
212212
int i;
213213
for(i = 0; (i < alphaLookup_.size()) && (alphaLookup_[i] < transformedValue); i += 2);
214214

215-
double startx = 0.0;
216-
double starty = 41.0;
217-
double endx = 364.0;
218-
double endy = starty;
219-
215+
double startx = 0.0f, starty, endx = 365.0f, endy;
220216
if(i == 0)
221217
{
222218
endx = alphaLookup_[0];
@@ -236,7 +232,7 @@ double ColorMap::alpha(double transformedValue) const
236232
}
237233

238234
double interp = (transformedValue - startx) / (endx - startx);
239-
double value = 1.0f - ((1.0f - interp) * starty + (interp) * endy) / 82.0f;
235+
double value = 1.0f - ((1.0f - interp) * starty + (interp) * endy) * (1.0f / 83.0f);
240236
return value;
241237
}
242238

src/Interface/Modules/Visualization/CreateStandardColorMapDialog.cc

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -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

213204
void ColormapPreview::removeDefaultLine()
@@ -218,18 +209,13 @@ void ColormapPreview::removeDefaultLine()
218209

219210
void 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

354338
double AlphaFunctionManager::pointYToAlpha(double y) const
355339
{
356-
return 1 - y / colorMapPreviewRect.height();
340+
return 1.0f - y / colorMapPreviewRect.height();
357341
}
358342

359343
QPointF AlphaFunctionManager::colorToPoint(double color) const

src/Interface/Modules/Visualization/CreateStandardColorMapDialog.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ namespace SCIRun {
5050
public:
5151
AlphaFunctionManager(const QPointF& start, const QPointF& end, SCIRun::Dataflow::Networks::ModuleStateHandle state, const boost::atomic<bool>& pulling);
5252
void clear();
53-
void insertEndpoints();
5453
void insert(const QPointF& p);
5554
bool alreadyExists(const QPointF& p) const;
5655
private:
@@ -85,7 +84,6 @@ namespace SCIRun {
8584
QWidget* parent = nullptr);
8685
void addDefaultLine();
8786
void addPoint(const QPointF& point);
88-
void addEndpoints() { alphaManager_.insertEndpoints(); }
8987
public Q_SLOTS:
9088
void clearAlphaPointGraphics();
9189
Q_SIGNALS:

src/Modules/Visualization/CreateStandardColorMap.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ void CreateStandardColorMap::execute()
6666

6767
//TODO cbright: pass computed alpha function from transient state to factory
6868
auto alphaPoints = state->getValue(Parameters::AlphaUserPointsVector).toVector();
69-
std::cout << alphaPoints << "\n";
7069
std::vector<double> points;
7170
for(auto point : alphaPoints)
7271
{

0 commit comments

Comments
 (0)