소스 검색

Todavia Limpiando el código, documentando

부모
커밋
bfb02711f8
11개의 변경된 파일132개의 추가작업 그리고 31개의 파일을 삭제
  1. 0
    2
      city.cpp
  2. 37
    2
      city.h
  3. 3
    1
      country.cpp
  4. 4
    0
      doublepoint.h
  5. 0
    7
      gispoi.cpp
  6. 0
    1
      gispoi.h
  7. 6
    0
      main.cpp
  8. 3
    4
      mainwindow.cpp
  9. 47
    3
      mainwindow.h
  10. 15
    10
      map.cpp
  11. 17
    1
      map.h

+ 0
- 2
city.cpp 파일 보기

@@ -1,7 +1,5 @@
1 1
 #include "city.h"
2 2
 
3
-
4
-
5 3
 void City::pushPoint(double x, double y) {
6 4
     geometry->push_back(DoublePoint(x,y));
7 5
 

+ 37
- 2
city.h 파일 보기

@@ -12,11 +12,46 @@
12 12
 class City {
13 13
 public:
14 14
     QVector<DoublePoint> *geometry;
15
+    
16
+    /// \fn City()
17
+    /// \~English
18
+    /// \brief default constructor
19
+    /// \~Spanish
20
+    /// \brief default constructor
21
+    ///
15 22
     City() {};
23
+
24
+    /// \fn pushPoint(double x, double y)
25
+    /// \~English
26
+    /// \brief push a point to the vector of points
27
+    /// \~Spanish
28
+    /// \brief añadir un punto al final del vector de puntos
29
+    ///
16 30
     void pushPoint(double x, double y);
17 31
 
18
-    virtual int getSize() { return geometry->size(); }
19
-    QVector<DoublePoint> *getGeometry() { return geometry; }
32
+    /// \fn getSize()
33
+    /// \~English
34
+    /// \brief get the size of the vector that contains the points
35
+    /// \~Spanish
36
+    /// \brief devuelve el tamaño del vector de puntos
37
+    ///
38
+    virtual int getSize() const { return geometry->size(); }
39
+
40
+    /// \fn QVector<DoublePoint> *getGeometry()
41
+    /// \~English
42
+    /// \brief get a pointer to the vector of points
43
+    /// \~Spanish
44
+    /// \brief devuelve un puntero al vector de puntos
45
+    ///
46
+    QVector<DoublePoint> *getGeometry() const { return geometry; }
47
+    
48
+
49
+    /// \fn ~City()
50
+    /// \~English
51
+    /// \brief destructor
52
+    /// \~Spanish
53
+    /// \brief destructor
54
+    ///    
20 55
     ~City() {delete geometry; }
21 56
 };
22 57
 

+ 3
- 1
country.cpp 파일 보기

@@ -54,8 +54,9 @@ bool Country::readInfoFromJSON(const QString &fileName) {
54 54
             }
55 55
         }
56 56
         else {
57
+            // for every city
57 58
             for (int i = 0; i <geometryArray.size() ; i++) {
58
-
59
+                // for every point in the city's polygon
59 60
                 for (int j = 0; j < geometryArray[i].toArray()[0].toArray().size(); j++) {
60 61
                     points->push_back(DoublePoint(
61 62
                                           geometryArray[i].toArray()[0].toArray()[j].toArray()[0].toDouble(),
@@ -75,4 +76,5 @@ bool Country::readInfoFromJSON(const QString &fileName) {
75 76
 
76 77
         ctr++;
77 78
     }
79
+    return true;
78 80
 }

+ 4
- 0
doublepoint.h 파일 보기

@@ -19,8 +19,12 @@ public:
19 19
     /// \fn DoublePoint(double xp, double yp)
20 20
     /// \~English
21 21
     /// \brief constructor that sets the coordinates
22
+    /// \param xp value for x
23
+    /// \param yp value for y
22 24
     /// \~Spanish
23 25
     /// \brief constructor que setea las coordenadas
26
+    /// \param xp valor para coordenada x
27
+    /// \param yp valor para coordenada y
24 28
     ///
25 29
     DoublePoint(double xp, double yp) { x = xp; y = yp; }
26 30
 };

+ 0
- 7
gispoi.cpp 파일 보기

@@ -1,12 +1,5 @@
1 1
 #include "gispoi.h"
2 2
 
3
-GISPOI::GISPOI()
4
-{
5
-}
6
-
7
-// Function odDistance(A,B)
8
-// Given two objects A and B of type GISPOI, uses their longitudes and
9
-// latitudes to compute and return their orthodromic distance in kilometers.
10 3
 
11 4
 double GISPOI::odDistance(const GISPOI &B) const {
12 5
     return EARTH_RADIUS * acos(

+ 0
- 1
gispoi.h 파일 보기

@@ -113,7 +113,6 @@ public:
113 113
              << lon << endl;
114 114
     }
115 115
 
116
-
117 116
     /// \fn print()
118 117
     /// \~English
119 118
     /// \brief Given two objects A and B of class GISPOI, uses their

+ 6
- 0
main.cpp 파일 보기

@@ -1,11 +1,16 @@
1
+#define QT_NO_DEBUG_OUTPUT
2
+
3
+
1 4
 #include "mainwindow.h"
2 5
 #include <QApplication>
3 6
 #include <cmath>
4 7
 #include <cassert>
5 8
 #include <fstream>
9
+
6 10
 using namespace std;
7 11
 
8 12
 
13
+
9 14
 // Function unitTests:
10 15
 // Some unit tests for the distance function
11 16
 
@@ -102,6 +107,7 @@ int main(int argc, char *argv[])
102 107
     MainWindow w;
103 108
     w.show();
104 109
 
110
+    cout << "Welcome to PR map!!!!" << endl;
105 111
     // open the file and check its validity
106 112
     // you need to use inFile.open(fileName.c_str()) instead of inFile.open(fileName)
107 113
     // since the open method expects a c-type string instead of a c++ string object 

+ 3
- 4
mainwindow.cpp 파일 보기

@@ -47,12 +47,11 @@ void MainWindow::drawPoints(GISPOI* gisLocations, unsigned int size) {
47 47
     myMap->drawPoints(gisLocations, size);
48 48
 }
49 49
 
50
-void MainWindow::drawLine(const GISPOI &city01, const GISPOI &city02) {
51
-    myMap->drawLine(city01, city02);
50
+void MainWindow::drawLine(const GISPOI &poi01, const GISPOI &poi02) {
51
+    myMap->drawLine(poi01, poi02);
52 52
 }
53 53
 
54
-MainWindow::~MainWindow()
55
-{
54
+MainWindow::~MainWindow() {
56 55
     delete ui;
57 56
     if (myMap != NULL) delete myMap;
58 57
 }

+ 47
- 3
mainwindow.h 파일 보기

@@ -13,17 +13,61 @@ class MainWindow : public QMainWindow
13 13
     Q_OBJECT
14 14
 
15 15
 public:
16
-    explicit MainWindow(QWidget *parent = 0);
16
+	// data members, I will declare as public for now
17 17
     Map *myMap;
18
+
19
+	/// \fn MainWindow(QWidget *parent = 0)
20
+    /// \~English
21
+    /// \brief default constructor
22
+    /// \param parent a pointer to this object's parent
23
+    /// \~Spanish
24
+    /// \brief constructor por defecto
25
+    /// \param parent puntero al padre de este objeto
26
+    ///
27
+    explicit MainWindow(QWidget *parent = 0);
28
+
29
+	/// \fn void drawPoints(GISPOI* gisLocations, unsigned int size)
30
+    /// \~English
31
+    /// \brief receives an array of points and its size, assigns it o
32
+    ///        an array inside the myMap object.
33
+    /// \param gisLocations an array of GISPOI objects in which we would
34
+    ///                     like to draw points
35
+    /// \param size size of the array
36
+    /// \~Spanish
37
+    /// \brief recibe un arreglo de puntos y su tamañano y lo asigna
38
+    ///        a un arreglo dentro del objeto myMap.
39
+    /// \param gisLocations un arreglo de objetos de clase GISPOI en los que 
40
+    ///                     deseamos que aparezcan dibujados puntos.
41
+    /// \param size tamaño del array
42
+    ///
18 43
     void drawPoints(GISPOI* gisLocations, unsigned int size);
19
-    void drawLine(const GISPOI &city01, const GISPOI &city02);
44
+
45
+	/// \fn void drawLine(const GISPOI &city01, const GISPOI &city02)
46
+    /// \~English
47
+    /// \brief receives reference to two objects of class GISPOIO and 
48
+    ///        registers that a segment shall be painted between them in the map.
49
+    /// \param poi01 one of the two GISPOI object ends of the segment  
50
+    /// \param poi02 the other of the two GISPOI object ends of the segment
51
+    /// \~Spanish
52
+    /// \brief recibe referencia a dos objetos de clase GISPOI y registra que 
53
+    ///        que se pintará una linea entre ellos dentro del mapa.
54
+    /// \param poi01 una de los puntos que unirá la línea
55
+    /// \param poi02 el otro de los extremos que unirá el segmento
56
+    ///
57
+    void drawLine(const GISPOI &poi01, const GISPOI &poi02);
58
+
59
+	/// \fn ~MainWindow()
60
+    /// \~English
61
+    /// \brief destructor
62
+    /// \~Spanish
63
+    /// \brief destructor
64
+    ///
20 65
     ~MainWindow();
21 66
 
22 67
 private:
23 68
     Ui::MainWindow *ui;
24 69
 
25 70
 protected:
26
-    void paintEventOLD(QPaintEvent *event);
27 71
 };
28 72
 
29 73
 #endif // MAINWINDOW_H

+ 15
- 10
map.cpp 파일 보기

@@ -45,28 +45,38 @@ unsigned int qpASize = 0;
45 45
 
46 46
 void Map::paintEvent(QPaintEvent *) {
47 47
 
48
-    // the QPainter is the 'canvas' to which we will draw
49
-    // the QPen is the pen that will be used to draw to the 'canvas'
50 48
 
51 49
     this->setWindowTitle("PR Visualization");
52 50
     QDesktopWidget widget;
53 51
     QRect mainScreenSize = widget.availableGeometry(widget.primaryScreen());
54 52
 
55 53
 
54
+    // Creating the arrays that will hold the points for the cities
56 55
     if (qpASize == 0) {
57
-        //qDebug() << "creating the arrays " << qpArraySize;
58 56
         for (int i = 0; i < 100; i++) {
59 57
             qpA[i] = new QPoint[20000];
60 58
         }
61 59
     }
62 60
 
61
+    // the QPainter is the 'canvas' to which we will draw
62
+    // the QPen is the pen that will be used to draw to the 'canvas
63 63
     QPainter *p = new QPainter(this);
64 64
     QPen myPen;
65 65
 
66
+    myPen.setWidth(1);
67
+    myPen.setColor(QColor(0x100000));
68
+    myPen.setBrush(QBrush(Qt::black));
69
+
70
+    p->setPen(myPen);
71
+
66 72
     double factorX, factorY;
67 73
 
68
-    double diffX = myCountry->maxX - myCountry->minX > 0 ? myCountry->maxX - myCountry->minX : myCountry->minX - myCountry->maxX;
69
-    double diffY = myCountry->maxY - myCountry->minY > 0 ? myCountry->maxY - myCountry->minY : myCountry->minY - myCountry->maxY;
74
+    // Computing the factors by which we'll scale the x and y coordinates.
75
+
76
+    double diffX = myCountry->maxX - myCountry->minX > 0 ?
77
+                myCountry->maxX - myCountry->minX : myCountry->minX - myCountry->maxX;
78
+    double diffY = myCountry->maxY - myCountry->minY > 0 ?
79
+                myCountry->maxY - myCountry->minY : myCountry->minY - myCountry->maxY;
70 80
 
71 81
     if (diffX > diffY) resize(mainScreenSize.width() * 0.5 , 0.5 * mainScreenSize.width()*(diffY/diffX));
72 82
     else               resize(mainScreenSize.width() * 0.5,  0.5 * mainScreenSize.width()*(diffX/diffY));
@@ -74,11 +84,6 @@ void Map::paintEvent(QPaintEvent *) {
74 84
     factorX = this->width()  / diffX;
75 85
     factorY = this->height() / diffY;
76 86
 
77
-    myPen.setWidth(1);
78
-    myPen.setColor(QColor(0x100000));
79
-    myPen.setBrush(QBrush(Qt::black));
80
-
81
-    p->setPen(myPen);
82 87
 
83 88
     int colorCtr = 0;
84 89
     QMap<QString,City*>::iterator it;

+ 17
- 1
map.h 파일 보기

@@ -4,7 +4,6 @@
4 4
 #include <QWidget>
5 5
 #include <QMap>
6 6
 #include <QRgb>
7
-// #include <census.h>
8 7
 #include <country.h>
9 8
 #include <gispoi.h>
10 9
 #include <QVector>
@@ -45,6 +44,12 @@ public:
45 44
             QPair<const GISPOI *, const GISPOI *> (&city01, &city02));
46 45
     }
47 46
     
47
+    /// \fn ~Map)()
48
+    /// \~English
49
+    /// \brief destructor
50
+    /// \~Spanish
51
+    /// \brief destructor
52
+    ///
48 53
     ~Map();
49 54
 signals:
50 55
 
@@ -57,6 +62,17 @@ private:
57 62
     QVector < QPair<const GISPOI *,const GISPOI *> > cityLines;
58 63
 
59 64
 protected:
65
+
66
+    /// \fn paintEvent(QPaintEvent *event);
67
+    /// \~English
68
+    /// \brief function that is called every time the map widget 
69
+    ///        generates a paint event. It draws the polygons and lines
70
+    ///        of the map.
71
+    /// \~Spanish
72
+    /// \brief función que se invoca cada vez que el widget genera un
73
+    ///        evento de pintar. Dibuja los polígonos y las lineas en el
74
+    ///        mapa.
75
+    ///
60 76
     void paintEvent(QPaintEvent *event);
61 77
 
62 78
 public slots: