From 39563ec1763c9455236c9868885a2f5389569536 Mon Sep 17 00:00:00 2001 From: marco <marco@5a81b35b-ba03-0410-adc8-b2c5c5119f08> Date: Tue, 9 Mar 2010 08:26:47 +0000 Subject: [PATCH] implemented SetColor/GetColor for MapIso git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@1789 5a81b35b-ba03-0410-adc8-b2c5c5119f08 --- modules/gfx/pymod/export_map.cc | 2 ++ modules/gfx/src/impl/octree_isocont.cc | 2 +- modules/gfx/src/impl/octree_isocont.hh | 6 +++-- modules/gfx/src/map_iso.cc | 8 +++--- modules/gfx/src/map_iso.hh | 35 ++++++++++++++++++-------- 5 files changed, 36 insertions(+), 17 deletions(-) diff --git a/modules/gfx/pymod/export_map.cc b/modules/gfx/pymod/export_map.cc index 37207916c..00ffbf165 100644 --- a/modules/gfx/pymod/export_map.cc +++ b/modules/gfx/pymod/export_map.cc @@ -57,6 +57,8 @@ void export_Map() .def("GetMean", &MapIso::GetMean) .def("Rebuild", &MapIso::Rebuild) .def("SetNSF",&MapIso::SetNSF) + .def("SetColor", &MapIso::SetColor) + .def("GetColor", &MapIso::GetColor, return_value_policy<copy_const_reference>()) .def("SetDebugOctree", &MapIso::SetDebugOctree) ; diff --git a/modules/gfx/src/impl/octree_isocont.cc b/modules/gfx/src/impl/octree_isocont.cc index 1eea253b8..b46979651 100644 --- a/modules/gfx/src/impl/octree_isocont.cc +++ b/modules/gfx/src/impl/octree_isocont.cc @@ -93,7 +93,7 @@ VertexID OctreeIsocont::GetOrGenVert(img::RealSpatialImageState* map, float val2=map->Value(p2); float t=(level_-val1)/(val2-val1); VertexID id=va_.Add(vert1*(1.0f-t)+vert2*t, geom::Vec3(1,0,0), - gfx::Color::RED); + color_); edge_map_.insert(std::make_pair(key, id)); return id; } diff --git a/modules/gfx/src/impl/octree_isocont.hh b/modules/gfx/src/impl/octree_isocont.hh index 913de29c9..128c18a51 100644 --- a/modules/gfx/src/impl/octree_isocont.hh +++ b/modules/gfx/src/impl/octree_isocont.hh @@ -59,8 +59,9 @@ private: static EdgeDesc EDGE_DESC[12]; public: typedef boost::unordered_map<uint32_t, VertexID> EdgeMap; - OctreeIsocont(IndexedVertexArray& va, float level, bool triangles): - va_(va), level_(level), triangles_(triangles) + OctreeIsocont(IndexedVertexArray& va, float level, bool triangles, + const Color& color): + va_(va), level_(level), triangles_(triangles), color_(color) { } bool VisitNode(const impl::OctreeNode& node, uint8_t level, const img::Extent& ext) @@ -77,6 +78,7 @@ private: float level_; EdgeMap edge_map_; bool triangles_; + Color color_; }; diff --git a/modules/gfx/src/map_iso.cc b/modules/gfx/src/map_iso.cc index f0c07cf64..2dec10e3b 100644 --- a/modules/gfx/src/map_iso.cc +++ b/modules/gfx/src/map_iso.cc @@ -53,7 +53,8 @@ MapIso::MapIso(const String& name, const img::MapHandle& mh, float level): normals_calculated_(false), alg_(0), smoothf_(0.2), - debug_octree_(false) + debug_octree_(false), + color_(Color::WHITE) { // TODO replace with def mat for this gfx obj type @@ -73,7 +74,8 @@ MapIso::MapIso(const String& name, const img::MapHandle& mh, level_(level), normals_calculated_(false), alg_(a), - debug_octree_(false) + debug_octree_(false), + color_(Color::WHITE) { // TODO replace with def mat for this gfx obj type SetMat(0.0,1.0,0.1,32.0); @@ -239,7 +241,7 @@ void MapIso::Rebuild() va_.SetMode(0x2); normals_calculated_=false; bool triangles=this->GetRenderMode()!=gfx::RenderMode::SIMPLE; - impl::OctreeIsocont cont(va_, level_, triangles); + impl::OctreeIsocont cont(va_, level_, triangles, color_); octree_.VisitDF(cont); // for normal debugging #if 0 diff --git a/modules/gfx/src/map_iso.hh b/modules/gfx/src/map_iso.hh index 445559158..3648697f0 100644 --- a/modules/gfx/src/map_iso.hh +++ b/modules/gfx/src/map_iso.hh @@ -75,24 +75,37 @@ public: /// \brief get std dev of map. float GetStdDev() const; - + + /// \brief set color + /// + /// By default, the color is white. + /// \sa GetColor() + void SetColor(const Color& color) + { + color_=color; + this->FlagRebuild(); + } + /// \brief get color + /// \sa SetColor() + const Color& GetColor() const { return color_; } void SetNSF(float smoothf); void SetDebugOctree(bool flag) { debug_octree_=flag; } protected: virtual void CustomPreRenderGL(bool flag); private: - img::MapHandle mh_; + img::MapHandle mh_; impl::MapOctree octree_; - float level_; - bool normals_calculated_; - uint alg_; - float smoothf_; - float min_; - float max_; - float std_dev_; - float min_max_; - bool debug_octree_; + float level_; + bool normals_calculated_; + uint alg_; + float smoothf_; + float min_; + float max_; + float std_dev_; + float min_max_; + bool debug_octree_; + Color color_; }; -- GitLab