// Initialize
int initMatrix(Matrix *matrix,int rows, int cols)
{
    if (rows <= 0 || cols <= 0)
        return 5;

    writeRows(matrix, rows);
    writeColumns(matrix, cols);
    
    return 0;
}
示例#2
0
    bool Gui_ResultFileWriter::saveSelection(const ResultMap& res_map, const std::vector<int>& idxs){

        if(idxs.empty()){
            NoSelectionMessage msg;
            msg.set_transient_for(*((Gtk::Window*) m_parent_widg->get_toplevel()));
            msg.run();
            return false;
        }
        Glib::ustring file_uri;

        bool detailed_result(false);

        while(file_uri.empty()){
            int result;
            {
            SaveModeMessage save_mode;
            save_mode.set_transient_for(*((Gtk::Window*) m_parent_widg->get_toplevel()));
            result = save_mode.run();
            }
            switch(result){
                case Gtk::RESPONSE_ACCEPT: //summary
                    detailed_result = false;
                    break;
                case Gtk::RESPONSE_OK: //Detail
                    detailed_result = true;
                    break;

                default:
                    return false;
                    break;
            }
            std::string dir_uri;

            if(m_out_file)
                if (m_out_file->query_exists())
                    dir_uri = m_out_file->get_uri();


            SaveFileChooser file_chooser(dir_uri);
            file_chooser.set_transient_for(*((Gtk::Window*) m_parent_widg->get_toplevel()));
            result = file_chooser.run();
            if(result == Gtk::RESPONSE_OK)
                file_uri = file_chooser.get_uri();
        }

        m_out_file = Gio::File::create_for_uri(file_uri);

        writeHeader(detailed_result,res_map,idxs);
        writeRows(detailed_result,res_map,idxs);
        m_up_to_date = true;
        return true;
    }
//Initialize
int initMatrix(Matrix *matrix,int rows, int cols)
{
    int i;

    if (rows <= 0 || cols <= 0) return 5;
    writeRows(matrix, rows);
    writeColumns(matrix, cols);
    matrix->values = malloc(rows * sizeof(float*));
    for(i=0; i<rows; i++)
    {
        *(matrix->values + i) = malloc(cols * sizeof(float));
    }
    return 0;
}