Empirical
Classes | Public Member Functions | Public Attributes | List of all members
emp::web::SpatialGridTreeVisualization< NODE, TREE_TYPE > Class Template Reference

#include <visualizations.h>

Inheritance diagram for emp::web::SpatialGridTreeVisualization< NODE, TREE_TYPE >:

Classes

struct  LegendNode
 
struct  TreeEdge
 

Public Member Functions

emp::vector< int > GetLocHistory (int id)
 
 SpatialGridTreeVisualization (int width, int height)
 
virtual void Setup ()
 

Public Attributes

int grid_width = 10
 
int grid_height = 10
 
int legend_cell_size = 15
 
D3::Selection legend
 
std::function< void(NODE, int)> node_mouseover
 
std::function< std::string(NODE, int)> color_fun_node
 
std::function< std::string(NODE, int)> dark_color_fun
 
std::function< std::string(TreeEdge, int)> color_fun_link
 
std::function< void(LegendNode, int)> legend_mouseover
 
std::function< void(LegendNode, int)> legend_mouseout
 

Constructor & Destructor Documentation

template<typename NODE = SpatialGridTreeNode, template< typename > class TREE_TYPE = TreeVisualization>
emp::web::SpatialGridTreeVisualization< NODE, TREE_TYPE >::SpatialGridTreeVisualization ( int  width,
int  height 
)
inline

Member Function Documentation

template<typename NODE = SpatialGridTreeNode, template< typename > class TREE_TYPE = TreeVisualization>
emp::vector<int> emp::web::SpatialGridTreeVisualization< NODE, TREE_TYPE >::GetLocHistory ( int  id)
inline
template<typename NODE = SpatialGridTreeNode, template< typename > class TREE_TYPE = TreeVisualization>
virtual void emp::web::SpatialGridTreeVisualization< NODE, TREE_TYPE >::Setup ( )
inlinevirtual

Member Data Documentation

template<typename NODE = SpatialGridTreeNode, template< typename > class TREE_TYPE = TreeVisualization>
std::function<std::string(TreeEdge, int)> emp::web::SpatialGridTreeVisualization< NODE, TREE_TYPE >::color_fun_link
Initial value:
= [this](TreeEdge d, int i){
return this->color_fun_node(d.source(), i);
}
template<typename NODE = SpatialGridTreeNode, template< typename > class TREE_TYPE = TreeVisualization>
std::function<std::string(NODE, int)> emp::web::SpatialGridTreeVisualization< NODE, TREE_TYPE >::color_fun_node
Initial value:
= [this](NODE d, int i){
if (d.loc() < 0) {
return std::string("black");
}
double x = (d.loc() % grid_width) - grid_width/2;
double y = (d.loc() / grid_width) - grid_height/2;
double r = sqrt(emp::Pow((int)x,2)+emp::Pow((int)y,2)) / sqrt(emp::Pow(grid_width,2)+emp::Pow(grid_height,2));
(void) r;
double theta = atan2(y, x)*(180/emp::PI);
(void) theta;
char * color = (char *) EM_ASM_INT({
var text = d3.hcl($1, 150, $0*175).toString();
var buffer = Module._malloc(text.length+1);
Module.writeStringToMemory(text, buffer);
return buffer;
}, r, theta);
std::string result = std::string(color);
free(color);
return result;
}
template<typename NODE = SpatialGridTreeNode, template< typename > class TREE_TYPE = TreeVisualization>
std::function<std::string(NODE, int)> emp::web::SpatialGridTreeVisualization< NODE, TREE_TYPE >::dark_color_fun
Initial value:
= [this](NODE d, int i){
if (d.loc() < 0) {
return std::string("black");
}
double x = (d.loc() % grid_width) - grid_width/2;
double y = (d.loc() / grid_width) - grid_height/2;
double r = sqrt(emp::Pow((int)x,2)+emp::Pow((int)y,2)) / sqrt(emp::Pow(grid_width,2)+emp::Pow(grid_height,2));
(void) r;
double theta = atan2(y, x)*(180/emp::PI);
(void) theta;
char * color = (char *) EM_ASM_INT({
var text = d3.hcl($1, 150, $0*175).darker().toString();
var buffer = Module._malloc(text.length+1);
Module.writeStringToMemory(text, buffer);
return buffer;
}, r, theta);
std::string result = std::string(color);
free(color);
return result;
}
template<typename NODE = SpatialGridTreeNode, template< typename > class TREE_TYPE = TreeVisualization>
int emp::web::SpatialGridTreeVisualization< NODE, TREE_TYPE >::grid_height = 10
template<typename NODE = SpatialGridTreeNode, template< typename > class TREE_TYPE = TreeVisualization>
int emp::web::SpatialGridTreeVisualization< NODE, TREE_TYPE >::grid_width = 10
template<typename NODE = SpatialGridTreeNode, template< typename > class TREE_TYPE = TreeVisualization>
D3::Selection emp::web::SpatialGridTreeVisualization< NODE, TREE_TYPE >::legend
template<typename NODE = SpatialGridTreeNode, template< typename > class TREE_TYPE = TreeVisualization>
int emp::web::SpatialGridTreeVisualization< NODE, TREE_TYPE >::legend_cell_size = 15
template<typename NODE = SpatialGridTreeNode, template< typename > class TREE_TYPE = TreeVisualization>
std::function<void(LegendNode, int)> emp::web::SpatialGridTreeVisualization< NODE, TREE_TYPE >::legend_mouseout
Initial value:
= [this](LegendNode d, int i) {
legend.SelectAll("rect")
.Filter([d](LegendNode in_data){return d.loc() != in_data.loc();})
.SetClassed("faded", false);
GetSVG()->SelectAll(".node")
.Filter([d](LegendNode in_data){return d.loc() != in_data.loc();})
.SetClassed("faded", false);
EM_ASM_ARGS({emp.filter_fun = function(d){return d.source.loc != $0;}}, d.loc());
GetSVG()->SelectAll(".link").Filter("filter_fun").SetClassed("faded", false);
}
template<typename NODE = SpatialGridTreeNode, template< typename > class TREE_TYPE = TreeVisualization>
std::function<void(LegendNode, int)> emp::web::SpatialGridTreeVisualization< NODE, TREE_TYPE >::legend_mouseover
Initial value:
= [this](LegendNode d, int il) {
legend.SelectAll("rect").Filter([d](LegendNode in_data){return d.loc() != in_data.loc();}).SetClassed("faded", true);
GetSVG()->SelectAll(".node").Filter([d](LegendNode in_data){return d.loc() != in_data.loc();}).SetClassed("faded", true);
EM_ASM_ARGS({emp.filter_fun = function(d){return d.source.loc != $0;}}, d.loc());
GetSVG()->SelectAll(".link").Filter("filter_fun").SetClassed("faded", true);
}
template<typename NODE = SpatialGridTreeNode, template< typename > class TREE_TYPE = TreeVisualization>
std::function<void(NODE, int)> emp::web::SpatialGridTreeVisualization< NODE, TREE_TYPE >::node_mouseover

The documentation for this class was generated from the following file: