From dd9ac2d81190a2dea3881098af65d51bfc693414 Mon Sep 17 00:00:00 2001
From: Tobias Schmidt <tobias.schmidt@unibas.ch>
Date: Thu, 14 Jun 2012 11:12:03 +0200
Subject: [PATCH] fix ColorBy for custom properties when using no min/max
 values (fixes BZDNG-305 and BZDNG-279)

---
 modules/gfx/src/entity.cc             |  2 +-
 modules/mol/base/tests/test_entity.cc | 16 ++++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/modules/gfx/src/entity.cc b/modules/gfx/src/entity.cc
index dff4bfa1f..c48a544cf 100644
--- a/modules/gfx/src/entity.cc
+++ b/modules/gfx/src/entity.cc
@@ -968,7 +968,7 @@ void Entity::ColorBy(const String& prop,
                      const Color& c1, const Color& c2,
                      mol::Prop::Level level)
 {
-  std::pair<float,float> minmax = this->GetView().GetMinMax(prop);
+  std::pair<float,float> minmax = this->GetView().GetMinMax(prop, level);
   this->ColorBy(prop,c1,c2,minmax.first, minmax.second,level);
 }
 
diff --git a/modules/mol/base/tests/test_entity.cc b/modules/mol/base/tests/test_entity.cc
index 1b8b195bd..9539158d2 100644
--- a/modules/mol/base/tests/test_entity.cc
+++ b/modules/mol/base/tests/test_entity.cc
@@ -23,6 +23,7 @@
 #include <ost/geom/vec_mat_predicates.hh>
 #include <ost/mol/chem_class.hh>
 #include <ost/mol/mol.hh>
+#include <ost/mol/property_id.hh>
 #include <cmath>
 #define BOOST_TEST_DYN_LINK
 #include <boost/test/unit_test.hpp>
@@ -413,4 +414,19 @@ BOOST_AUTO_TEST_CASE(rename_atom)
    BOOST_CHECK_EQUAL(atom.GetName(), "B");
 }
 
+BOOST_AUTO_TEST_CASE(minmax)
+{
+  EntityHandle eh=make_test_entity();
+  EntityView ev = eh.CreateFullView();
+  mol::AtomViewList avl = ev.GetAtomList();
+  mol::AtomViewList::iterator i;
+  int n=0.0;
+  for (i=avl.begin(); i!=avl.end(); ++i, ++n) {
+    i->SetFloatProp("test", n);
+  }
+  std::pair<float,float> minmax = ev.GetMinMax("test", Prop::ATOM);
+  BOOST_CHECK_EQUAL(minmax.first, 0.0);
+  BOOST_CHECK_EQUAL(minmax.second, 7.0);
+}
+
 BOOST_AUTO_TEST_SUITE_END();
-- 
GitLab