Esempio n. 1
0
    bool TransferSourcesFile(wxString source, wxString target)
    {
        wxFileInputStream f_source(source);
        if (!f_source.Ok()) {
            wxLogMessage(wxT("Failed to read from %s"), source.c_str());
            return false;
        }
        wxFileOutputStream f_target(target);
        if (!f_target.Ok()) {
            wxLogMessage(wxT("Failed to write to %s"), target.c_str());
            return false;
        }

        wxTextInputStream istream(f_source);
        wxTextOutputStream ostream(f_target);
        for(;;) {
            wxString line = istream.ReadLine();
            wxString rest;

            if (f_source.Eof() && line.IsEmpty()) {
                break;
            }
            if (line.StartsWith(wxT("..\\..\\app\\"), &rest)) {
                line = rest.AfterFirst('\\');
            }
            ostream.WriteString(line + wxT("\n"));
        }
        return true;
    }
Esempio n. 2
0
    bool TransferProjectFile(wxString source, wxString target)
    {
        wxFileInputStream f_source(source);
        if (!f_source.Ok()) {
            wxLogMessage(wxT("Failed to read from %s"), source.c_str());
            return false;
        }
        wxFileOutputStream f_target(target);
        if (!f_target.Ok()) {
            wxLogMessage(wxT("Failed to write to %s"), target.c_str());
            return false;
        }

        wxTextInputStream istream(f_source);
        wxTextOutputStream ostream(f_target);
        for(;;) {
            wxString line = istream.ReadLine();

            if (f_source.Eof() && line.IsEmpty()) {
                break;
            }
            ostream.WriteString(line + wxT("\n"));
        }
        return true;
    }
bool is_straight_line_drawing(const Graph& g,
                              GridPositionMap drawing,
                              VertexIndexMap vm
                             )
{

    typedef typename graph_traits<Graph>::vertex_descriptor vertex_t;
    typedef typename graph_traits<Graph>::vertex_iterator vertex_iterator_t;
    typedef typename graph_traits<Graph>::edge_descriptor edge_t;
    typedef typename graph_traits<Graph>::edge_iterator edge_iterator_t;
    typedef typename graph_traits<Graph>::edges_size_type e_size_t;
    typedef typename graph_traits<Graph>::vertices_size_type v_size_t;

    typedef std::size_t x_coord_t;
    typedef std::size_t y_coord_t;
    typedef boost::tuple<edge_t, x_coord_t, y_coord_t> edge_event_t;
    typedef typename std::vector< edge_event_t > edge_event_queue_t;

    typedef tuple<y_coord_t, y_coord_t, x_coord_t, x_coord_t> active_map_key_t;
    typedef edge_t active_map_value_t;
    typedef std::map< active_map_key_t, active_map_value_t > active_map_t;
    typedef typename active_map_t::iterator active_map_iterator_t;


    edge_event_queue_t edge_event_queue;
    active_map_t active_edges;

    edge_iterator_t ei, ei_end;
    for(tie(ei,ei_end) = edges(g); ei != ei_end; ++ei)
    {
        edge_t e(*ei);
        vertex_t s(source(e,g));
        vertex_t t(target(e,g));
        edge_event_queue.push_back
        (make_tuple(e,
                    static_cast<std::size_t>(drawing[s].x),
                    static_cast<std::size_t>(drawing[s].y)
                   )
        );
        edge_event_queue.push_back
        (make_tuple(e,
                    static_cast<std::size_t>(drawing[t].x),
                    static_cast<std::size_t>(drawing[t].y)
                   )
        );
    }

    // Order by edge_event_queue by first, then second coordinate
    // (bucket_sort is a stable sort.)
    bucket_sort(edge_event_queue.begin(), edge_event_queue.end(),
                property_map_tuple_adaptor<edge_event_t, 2>()
               );

    bucket_sort(edge_event_queue.begin(), edge_event_queue.end(),
                property_map_tuple_adaptor<edge_event_t, 1>()
               );

    typedef typename edge_event_queue_t::iterator event_queue_iterator_t;
    event_queue_iterator_t itr_end = edge_event_queue.end();
    for(event_queue_iterator_t itr = edge_event_queue.begin();
            itr != itr_end; ++itr
       )
    {
        edge_t e(get<0>(*itr));
        vertex_t source_v(source(e,g));
        vertex_t target_v(target(e,g));
        if (drawing[source_v].y > drawing[target_v].y)
            std::swap(source_v, target_v);

        active_map_key_t key(get(drawing, source_v).y,
                             get(drawing, target_v).y,
                             get(drawing, source_v).x,
                             get(drawing, target_v).x
                            );

        active_map_iterator_t a_itr = active_edges.find(key);
        if (a_itr == active_edges.end())
        {
            active_edges[key] = e;
        }
        else
        {
            active_map_iterator_t before, after;
            if (a_itr == active_edges.begin())
                before = active_edges.end();
            else
                before = prior(a_itr);
            after = boost::next(a_itr);

            if (before != active_edges.end())
            {

                edge_t f = before->second;
                vertex_t e_source(source(e,g));
                vertex_t e_target(target(e,g));
                vertex_t f_source(source(f,g));
                vertex_t f_target(target(f,g));

                if (intersects(drawing[e_source].x,
                               drawing[e_source].y,
                               drawing[e_target].x,
                               drawing[e_target].y,
                               drawing[f_source].x,
                               drawing[f_source].y,
                               drawing[f_target].x,
                               drawing[f_target].y
                              )
                   )
                    return false;
            }

            if (after != active_edges.end())
            {

                edge_t f = after->second;
                vertex_t e_source(source(e,g));
                vertex_t e_target(target(e,g));
                vertex_t f_source(source(f,g));
                vertex_t f_target(target(f,g));

                if (intersects(drawing[e_source].x,
                               drawing[e_source].y,
                               drawing[e_target].x,
                               drawing[e_target].y,
                               drawing[f_source].x,
                               drawing[f_source].y,
                               drawing[f_target].x,
                               drawing[f_target].y
                              )
                   )
                    return false;
            }

            active_edges.erase(a_itr);

        }
    }

    return true;

}
Esempio n. 4
0
    bool TransferProjectFile(wxString source, wxString target)
    {
        bool in_section = false;

        wxFileInputStream f_source(source);
        if (!f_source.Ok()) {
            wxLogMessage(wxT("Failed to read from %s"), source.c_str());
            return false;
        }
        wxFileOutputStream f_target(target);
        if (!f_target.Ok()) {
            wxLogMessage(wxT("Failed to write to %s"), target.c_str());
            return false;
        }

        CSettings *cfg = wxGetApp().GetSettings();
        wxTextInputStream istream(f_source);
        wxTextOutputStream ostream(f_target);
        for(;;) {
            wxString line = istream.ReadLine();

            if (f_source.Eof() && line.IsEmpty()) {
                break;
            }
            if (in_section) {
                if (line.StartsWith(wxT("Edit1="))) {
                    line.Empty();
                    /* If we have a first include path, add it first. */
                    if(!cfg->m_firstidir.IsEmpty()) {
                        line += cfg->m_firstidir + wxT(";");
                    }
                    /* Add the include path of the build tree. */
                    if (!::wxIsAbsolutePath(cfg->m_buildpath)) {
                        line += cfg->m_topdir + wxT("\\");
                    }
					line += cfg->m_buildpath + wxT("\\include;");
                    /* Add the ICC specific include path of the source tree. */
                    if (!::wxIsAbsolutePath(cfg->m_source_dir)) {
                        line += cfg->m_topdir + wxT("\\");
                    }
                    line += cfg->m_source_dir + wxT("\\include\\crt\\iccavr;");
                    /* Add the include path of the source tree. */
                    if (!::wxIsAbsolutePath(cfg->m_source_dir)) {
                        line += cfg->m_topdir + wxT("\\");
                    }
                    line += cfg->m_source_dir + wxT("\\include");
                    /* If we have a last include path, add it last. */
                    if(!cfg->m_lastidir.IsEmpty()) {
                        line += wxT(";") + cfg->m_lastidir;
                    }
                    line = wxT("Edit1=") + line;
                    line.Replace(wxT("/"), wxT("\\"));
                }
                else if (line.StartsWith(wxT("Edit2="))) {
                    line = wxT("Edit2=");
                    if (!::wxIsAbsolutePath(cfg->m_buildpath)) {
                        line += cfg->m_topdir + wxT("\\");
                    }
                    line += cfg->m_buildpath + wxT("\\lib");
                    line.Replace(wxT("/"), wxT("\\"));
                }
                else if (line.StartsWith(wxT("Edit3="))) {
                    NUTCOMPONENTOPTION *opt = m_doc->FindOptionByName(NULL, "PLATFORM");
                    line = wxT("Edit3=");
                    if (opt && opt->nco_enabled && opt->nco_active) {
                        if (opt->nco_value && opt->nco_value[0]) {
                            line += wxString(opt->nco_value, wxConvLocal) + wxT(" ");
                        } else {
                            char *value = GetConfigValueOrDefault(m_doc->GetRepository(), opt->nco_compo, opt->nco_name);
                            if (value) {
                                line += wxString(value, wxConvLocal) + wxT(" ");
                                free(value);
                            }
                        }
                    }
                    opt = m_doc->FindOptionByName(NULL, "MCU_ATMEGA2561");
                    if (opt == NULL) {
                        opt = m_doc->FindOptionByName(NULL, "MCU_ATMEGA2560");
                    }
                    if (opt && opt->nco_enabled && opt->nco_active) {
                        line += wxT("_MCU_extended");
                    }
                    else {
                        line += wxT("_MCU_enhanced");
                    }
                    line += wxT(" __HARVARD_ARCH__");
                    line += wxT(" ATMEGA");
                    line += wxT(" CONST=\"\"");
                }
                else if (line.StartsWith(wxT("Edit13="))) {
                    char *value = NULL;
                    NUTCOMPONENTOPTION *opt = m_doc->FindOptionByName(NULL, "ICCAVR_STARTUP");
                    line = wxT("Edit13=");

                    if (opt && opt->nco_enabled && opt->nco_active) {
                        if (opt->nco_value) {
                            value = strdup(opt->nco_value);
                        } else {
                            value = GetConfigValueOrDefault(m_doc->GetRepository(), opt->nco_compo, opt->nco_name);
                        }
                    }
                    wxString valstr;
                    if (value) {
                        valstr = wxString(value, wxConvLocal).Trim().Trim(false);
                        free(value);
                    }
                    if (valstr.IsEmpty()) {
                        line += wxT("crtenutram");
                    } else {
                        line += valstr;
                    }
                    line += wxT(".o");
                }
                else if (line.StartsWith(wxT("Edit27="))) {
                    line = wxT("Edit27=");
                    if (!::wxIsAbsolutePath(cfg->m_buildpath)) {
                        line += cfg->m_topdir + wxT("\\");
                    }
                    line += cfg->m_buildpath + wxT("\\lib\\nutinit.o");
                    line.Replace(wxT("/"), wxT("\\"));
                }
            }
            else if (line[0] == '[') {
                in_section = line.IsSameAs(wxT("[Compiler Options]"), false);
            }
            ostream.WriteString(line + wxT("\n"));
        }
        return true;
    }