// ----------------------------------------------------------------------
   void
   CreateEstimatedEdgesTask::
   run( shawn::SimulationController& sc )
      throw( std::runtime_error )
   {
      VisualizationTask::run(sc);

      std::string pref = sc.environment().
         optional_string_param("prefix",DrawableEdgeEstimated::PREFIX);
      std::string node_prefix =
         sc.environment().
         optional_string_param("node_prefix",DrawableNodeDefault::PREFIX);
      GroupElement* grp = group(sc);

      for( shawn::World::const_node_iterator
              it    = visualization().world().begin_nodes(),
              endit = visualization().world().end_nodes();
           it != endit; ++it )
      {
         if( it->has_est_position())
         {
            const DrawableNode* dn = drawable_node(*it, node_prefix);
            DrawableEdgeEstimated* dee = new DrawableEdgeEstimated(*it, *dn, 
               DrawableEdgeEstimated::PREFIX);
            dee->init();
            visualization_w().add_element(dee);
            if( grp != NULL )
               grp->add_element(*dee);
         }
      }
   }
예제 #2
0
   // ----------------------------------------------------------------------
   void
   CreateEdgesTagTask::
   run( shawn::SimulationController& sc )
      throw( std::runtime_error )
   {
      VisualizationTask::run(sc);
#ifndef HAVE_BOOST_REGEX
      throw std::runtime_error("no boost::regex support compiled in");
#else
      boost::regex sources(sc.environment().required_string_param("source_regex"));
      boost::regex targets(sc.environment().required_string_param("target_regex"));
      std::string taglabel = sc.environment().required_string_param("tag");

      std::string pref = sc.environment().
         optional_string_param("prefix",DrawableEdgeDefault::PREFIX);
      std::string node_prefix =
         sc.environment().
         optional_string_param("node_prefix",DrawableNodeDefault::PREFIX);
      GroupElement* grp = group(sc);

      for( shawn::World::const_node_iterator
              it    = visualization().world().begin_nodes(),
              endit = visualization().world().end_nodes();
           it != endit; ++it )
      {
         
         if( boost::regex_search(get_stringtag(&*it,taglabel)->value(),sources))
            {
               for( shawn::Node::const_adjacency_iterator
                       ait    = it->begin_adjacent_nodes(),
                       endait = it->end_adjacent_nodes();
                    ait != endait; ++ait )
                  if( *it != *ait )
                     if( boost::regex_search(get_stringtag(&*ait,taglabel)->value(),targets) )
                        if( (ait->label() > it->label()) ||
                            (!boost::regex_search(get_stringtag(&*it,taglabel)->value(),targets)) ||
                            (!boost::regex_search(get_stringtag(&*ait,taglabel)->value(),sources)) )
                           {
                              const DrawableNode* dsrc =
                                 drawable_node(*it,node_prefix);
                              const DrawableNode* dtgt =
                                 drawable_node(*ait,node_prefix);
                              DrawableEdgeDefault* ded =
                                 new DrawableEdgeDefault(*it,*ait,*dsrc,*dtgt,pref);
                              ded->init();
                              visualization_w().add_element(ded);
                              if( grp != NULL )
                                 grp->add_element(*ded);
                           }
            }
      }
#endif
   }
예제 #3
0
   // ----------------------------------------------------------------------
   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);
         }
   }