// ---------------------------------------------------------------------- void CreateGroupTask:: run( shawn::SimulationController& sc ) throw( std::runtime_error ) { VisualizationTask::run(sc); GroupElement* ge = new GroupElement( sc.environment().required_string_param("group") ); ge->init(); visualization_w().add_element( ge ); }
// ---------------------------------------------------------------------- void VisualizationTaskCreate:: run( shawn::SimulationController& sc ) throw( std::runtime_error ) { Visualization* vis; require_world(sc); std::string name = sc.environment().optional_string_param( "vis", "visualization" ); visualization_keeper_w(sc).add(vis=new Visualization(name)); std::string type = sc.environment().optional_string_param( "node_type", "default" ); DrawableNodeFactoryHandle dnfh = sc.keeper_by_name_w<DrawableNodeKeeper>("DrawableNodeKeeper") ->find_w(sc.environment().optional_string_param("drawable_nodes", type)); sc.world_w().add_node_change_listener(*vis); vis->set_world( sc.world() ); vis->init(); DEBUG( logger(), "created visualization '" << name << "'" ); GroupElement* ge = new GroupElement( "all.nodes" ); ge->init(); vis->add_element(ge); for( shawn::World::const_node_iterator it = sc.world().begin_nodes(); it != sc.world().end_nodes(); ++it ) { DrawableNode *dn = dnfh->create(*it); dn->init(); vis->add_element(dn); ge->add_element(*dn); } }