Gps.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2009, CoroWare
00003  * All rights reserved.
00004  * 
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  * 
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of the Willow Garage, Stanford U. nor the names of its
00014  *       contributors may be used to endorse or promote products derived from
00015  *       this software without specific prior written permission.
00016  * 
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 
00030 #include "GPS.h"
00031 #include <stdio.h>
00032 
00033 //GPS Widget, the map is not displayed as of now as it would be against google maps rules without any payments to google. An open source solution has to be found
00034 
00035 Gps::Gps(){
00036 }
00037 
00038 
00039 void Gps::set_map_type(QString value)
00040 //changes the map type
00041 {
00042 }
00043 
00044 void Gps::check_size()
00045 //the size od the map if the size of the web widget
00046 {
00047 }
00048 
00049 void Gps::set_zoom(int value)
00050 //set the map zoom value
00051 {
00052 }
00053 
00054 void Gps::update_coord(double lat, double lon)
00055 //update the last coordinate value
00056 {
00057 }
00058 
00059 
00060 void Gps::selection_changed()
00061 //the itinerary selection has changed, therefore change the path that is displayed
00062 {
00063 }
00064 
00065 void Gps::start_clicked()
00066 //the button start has been clicked. So we start the itinary
00067 {
00068     started = true;
00069     path.clear();
00070     QList<QListWidgetItem *> l = list_widget->findItems(QString("New Itinerary"),Qt::MatchExactly);
00071     if(l.count()==0)
00072         list_widget->insertItem(0,QString("New Itinerary"));
00073     list_widget->setCurrentItem(list_widget->item(0));
00074 
00075 }
00076 
00077 void Gps::stop_clicked()
00078 //the button stop has been clicked. Stop the itinerary
00079 {
00080     started = false;
00081     start_pos_set = false;
00082 
00083 }
00084 
00085 void Gps::save_clicked()
00086 //the button save has been clicked. Save the itinerary in a file
00087 {
00088     QList<QListWidgetItem *> l = list_widget->findItems(QString("New Itinerary"),Qt::MatchExactly);
00089     if(l.count() != 0){
00090         QString file = QFileDialog::getSaveFileName();
00091         FILE *f;
00092         QByteArray ba = file.toLatin1();
00093         if((f = fopen(ba.data(),"w+"))!=NULL){
00094             ba = path.toLatin1();
00095             fprintf(f,"%s",ba.data());
00096             fclose(f);
00097                 QListWidgetItem *tmp = list_widget->takeItem(0);
00098                 delete tmp;
00099 
00100             list_widget->addItem(file);
00101             loaded_files.append(path);
00102         }
00103     }
00104 }
00105 
00106 void Gps::setList(QListWidget *l)
00107 //gives the pointer to the list widget to display the itineraries
00108 {
00109     list_widget = l;
00110 }
00111 
00112 void Gps::load_clicked()
00113 //the button stop has been clicked. Load the itinerary file given by the user
00114 {
00115     QStringList files = QFileDialog::getOpenFileNames();
00116 
00117     FILE *f;
00118     QByteArray ba;
00119     foreach (QString  s, files) {
00120         ba = s.toLatin1();
00121         f = fopen(ba.data(),"r+");
00122         char* c = (char*) malloc (10000);
00123 
00124         if(fgets(c,10000,f)!=NULL){
00125             QString *s = new QString(c);
00126             loaded_files.append(*s);
00127             list_widget->addItem(ba.data());
00128             list_widget->setCurrentItem(list_widget->item(list_widget->count() - 1));
00129             delete s;
00130         }
00131         fclose(f);
00132 
00133 
00134     }
00135     url.removeQueryItem("markers");
00136     check_size();
00137     selection_changed();
00138 
00139 }
00140 


corobot_teleop
Author(s):
autogenerated on Wed Aug 26 2015 11:09:59