Skip to content

Commit 3e000f3

Browse files
author
Haydelj
committed
removed preview size dependency from the internal representation of colormaps
1 parent 31d88ec commit 3e000f3

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/Core/Datatypes/ColorMap.cc

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

208208
double ColorMap::alpha(double transformedValue) const
209209
{
210-
transformedValue *= 365.0f;
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.0f, starty, endx = 365.0f, endy;
215+
double startx = 0.0f, starty, endx = 1.0f, endy;
216216
if(i == 0)
217217
{
218218
endx = alphaLookup_[0];
@@ -232,7 +232,7 @@ double ColorMap::alpha(double transformedValue) const
232232
}
233233

234234
double interp = (transformedValue - startx) / (endx - startx);
235-
double value = 1.0f - ((1.0f - interp) * starty + (interp) * endy) * (1.0f / 83.0f);
235+
double value = ((1.0f - interp) * starty + (interp) * endy);
236236
return value;
237237
}
238238

src/Interface/Modules/Visualization/CreateStandardColorMapDialog.cc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ using namespace SCIRun::Core::Datatypes;
3838

3939
typedef SCIRun::Modules::Visualization::CreateStandardColorMap CreateStandardColorMapModule;
4040

41+
namespace
42+
{
43+
const double colormapPreviewHeight = 83;
44+
const double colormapPreviewWidth = 365;
45+
const QRectF colorMapPreviewRect(0, 0, colormapPreviewWidth, colormapPreviewHeight);
46+
}
4147

4248
CreateStandardColorMapDialog::CreateStandardColorMapDialog(const std::string& name, ModuleStateHandle state,
4349
QWidget* parent /* = 0 */)
@@ -97,7 +103,7 @@ void CreateStandardColorMapDialog::pullSpecial()
97103
for (const auto& p : pointsVec)
98104
{
99105
auto pVec = p.toVector();
100-
previewColorMap_->addPoint(QPointF(pVec[0].toDouble(), pVec[1].toDouble()));
106+
previewColorMap_->addPoint(QPointF(pVec[0].toDouble() * colormapPreviewWidth, (1.0f - pVec[1].toDouble()) * colormapPreviewHeight));
101107
}
102108
}
103109
}
@@ -159,13 +165,6 @@ AlphaFunctionManager::AlphaFunctionManager(const QPointF& start, const QPointF&
159165
{
160166
}
161167

162-
namespace
163-
{
164-
const double colormapPreviewHeight = 83;
165-
const double colormapPreviewWidth = 365;
166-
const QRectF colorMapPreviewRect(0, 0, colormapPreviewWidth, colormapPreviewHeight);
167-
}
168-
169168
ColormapPreview::ColormapPreview(QGraphicsScene* scene, ModuleStateHandle state,
170169
const boost::atomic<bool>& pulling,
171170
QWidget* parent)
@@ -250,7 +249,8 @@ void AlphaFunctionManager::pushToState()
250249
Variable::List alphaPointsVec;
251250
//strip endpoints before saving user-added points
252251
auto begin = alphaPoints_.begin(), end = alphaPoints_.end();
253-
std::for_each(begin, end, [&](const QPointF& p) { alphaPointsVec.emplace_back(Name("alphaPoint"), makeAnonymousVariableList(p.x(), p.y())); });
252+
std::for_each(begin, end, [&](const QPointF& p) { alphaPointsVec.emplace_back(Name("alphaPoint"),
253+
makeAnonymousVariableList(p.x()/colormapPreviewWidth, 1.0f - p.y()/colormapPreviewHeight)); });
254254
state_->setValue(Parameters::AlphaUserPointsVector, alphaPointsVec);
255255
}
256256
else

0 commit comments

Comments
 (0)