├── README.md ├── color.cpp ├── color.h ├── feature.cpp ├── feature.h ├── geofile.cpp ├── geofile.h ├── layer.cpp ├── layer.h ├── main.cpp ├── map.cpp ├── map.h ├── mywidget.cpp ├── mywidget.cpp.autosave ├── mywidget.h ├── mywidget.h.autosave ├── opengl1.pro ├── opengl1.pro.user ├── point.cpp ├── point.h ├── style.cpp ├── style.h ├── stylefile.cpp ├── stylefile.h ├── widget.cpp ├── widget.h └── widget.ui /README.md: -------------------------------------------------------------------------------- 1 | # QtGIS 2 | GIS system using C++, Qt, OpenGL 3 | -------------------------------------------------------------------------------- /color.cpp: -------------------------------------------------------------------------------- 1 | #include "color.h" 2 | 3 | Color::Color() 4 | { 5 | Red=0; 6 | Green=0; 7 | Blue=0; 8 | } 9 | 10 | void Color::LoadColor(QString colStr){ 11 | int r,g,b; 12 | r= colStr.split(',')[0].toInt(); 13 | g= colStr.split(',')[1].toInt(); 14 | b= colStr.split(',')[2].toInt(); 15 | Green=g;Red=r;Blue=b; 16 | } 17 | -------------------------------------------------------------------------------- /color.h: -------------------------------------------------------------------------------- 1 | #ifndef COLOR_H 2 | #define COLOR_H 3 | #include 4 | #include 5 | #include 6 | 7 | class Color 8 | { 9 | public: 10 | Color(); 11 | void LoadColor(QString colStr); 12 | int Red,Green,Blue; 13 | }; 14 | 15 | #endif // COLOR_H 16 | -------------------------------------------------------------------------------- /feature.cpp: -------------------------------------------------------------------------------- 1 | #include "feature.h" 2 | 3 | Feature::Feature() 4 | { 5 | 6 | } 7 | 8 | void Feature::LoadFeature(QTextStream *textStream){ 9 | QString line=textStream->readLine(); 10 | this->feature_type=line.toInt(); 11 | 12 | Point *pt; 13 | while (true) { 14 | Point p; 15 | pt=&p; 16 | if(pt->LoadPoint(textStream,pt)){ 17 | this->pts.push_back(*pt); 18 | } 19 | else { 20 | break; 21 | } 22 | } 23 | } 24 | 25 | void Feature::DrawFeature(){ 26 | 27 | } 28 | -------------------------------------------------------------------------------- /feature.h: -------------------------------------------------------------------------------- 1 | #ifndef FEATURE_H 2 | #define FEATURE_H 3 | #include "point.h" 4 | #include 5 | #include 6 | #include 7 | 8 | class Feature 9 | { 10 | public: 11 | Feature(); 12 | int feature_type; 13 | void LoadFeature(QTextStream *textStream); 14 | void DrawFeature(); 15 | 16 | std::vector pts; 17 | }; 18 | 19 | #endif // FEATURE_H 20 | -------------------------------------------------------------------------------- /geofile.cpp: -------------------------------------------------------------------------------- 1 | #include "geofile.h" 2 | 3 | GeoFile::GeoFile() 4 | { 5 | 6 | } 7 | 8 | void GeoFile::LoadFile(QString filePath){ 9 | QFile file(filePath); 10 | file.open(QIODevice::ReadOnly); 11 | QTextStream textStream(&file); 12 | 13 | map->LoadMap(&textStream); 14 | 15 | file.close(); 16 | } 17 | -------------------------------------------------------------------------------- /geofile.h: -------------------------------------------------------------------------------- 1 | #ifndef GEOFILE_H 2 | #define GEOFILE_H 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "map.h" 9 | #include "layer.h" 10 | 11 | class GeoFile 12 | { 13 | public: 14 | GeoFile(); 15 | Map *map; 16 | 17 | void LoadFile(QString filePath); 18 | }; 19 | 20 | #endif // GEOFILE_H 21 | -------------------------------------------------------------------------------- /layer.cpp: -------------------------------------------------------------------------------- 1 | #include "layer.h" 2 | 3 | Layer::Layer() 4 | { 5 | layer_name=""; 6 | layer_name_size=0; 7 | target_count=0; 8 | } 9 | 10 | void Layer::LoadLayer(QTextStream *textStream){ 11 | QString line1 = textStream->readLine(); 12 | QString line2 = textStream->readLine(); 13 | QString line3 = textStream->readLine(); 14 | 15 | int s,c;QString n ; 16 | s=line1.toInt(); 17 | layer_name_size=s; 18 | n=line2.split('\n')[0]; 19 | layer_name=n; 20 | c=line3.toInt(); 21 | target_count=c; 22 | 23 | for(int i=0;i 4 | #include 5 | #include 6 | #include 7 | #include "style.h" 8 | 9 | class Layer 10 | { 11 | public: 12 | Layer(); 13 | int layer_name_size; 14 | QString layer_name; 15 | int target_count; 16 | void LoadLayer(QTextStream* textStream); 17 | Style layer_style; 18 | 19 | std::vector features; 20 | }; 21 | 22 | #endif // LAYER_H 23 | -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include "mywidget.h" 3 | #include 4 | #include "geofile.h" 5 | #include "stylefile.h" 6 | 7 | int main(int argc, char *argv[]) 8 | { 9 | QApplication a(argc, argv); 10 | //Widget w; 11 | //w.show(); 12 | 13 | // Load data 14 | Map map; 15 | GeoFile geoFile; 16 | geoFile.map=↦ 17 | geoFile.LoadFile("/home/kyh/Documents/Qt/practise_3/utf8/china.dat"); 18 | 19 | // Load style 20 | StyleFile styleFile; 21 | styleFile.map=↦ 22 | styleFile.LoadStyle("/home/kyh/Documents/Qt/practise_3/utf8/china.opt"); 23 | 24 | // Map show 25 | MyWidget myWidget; 26 | myWidget.map=↦ 27 | 28 | 29 | myWidget.resize(800,600); 30 | myWidget.paintGL(); 31 | myWidget.show(); 32 | 33 | return a.exec(); 34 | } 35 | -------------------------------------------------------------------------------- /map.cpp: -------------------------------------------------------------------------------- 1 | #include "map.h" 2 | 3 | Map::Map() 4 | { 5 | } 6 | 7 | void Map::LoadMap(QTextStream *textStream){ 8 | QString line1 = textStream->readLine(); 9 | QString line2 = textStream->readLine(); 10 | QString line3 = textStream->readLine(); 11 | 12 | double l,t,r,b,c; 13 | l=line1.split(',')[0].toDouble(); 14 | this->left=l; 15 | 16 | t=line1.split(',')[1].toDouble(); 17 | this->top=t; 18 | 19 | r=line2.split(',')[0].toDouble(); 20 | this->right=r; 21 | 22 | b=line2.split(',')[1].toDouble(); 23 | this->bottom=b; 24 | 25 | c=line3.toDouble(); 26 | this->layerCount=c; 27 | 28 | for(int i=0;ireadLine() ; 38 | if(this->layerCount!= line.toInt()){ 39 | return; 40 | } 41 | for(int i=0;ireadLine() ; 43 | 44 | int index=0; 45 | for(int i=0;i 4 | #include 5 | #include "layer.h" 6 | #include "style.h" 7 | 8 | class Map 9 | { 10 | public: 11 | Map(); 12 | double left,top,right,bottom; 13 | int layerCount; 14 | Layer LAYER; 15 | void LoadMap(QTextStream *textStream); 16 | void LoadStyle(QTextStream *textStream); 17 | std::vector LAYERS; 18 | }; 19 | 20 | #endif // MAP_H 21 | -------------------------------------------------------------------------------- /mywidget.cpp: -------------------------------------------------------------------------------- 1 | #include "mywidget.h" 2 | 3 | MyWidget::MyWidget() 4 | { 5 | 6 | } 7 | void MyWidget::initializeGL(){ 8 | glClearColor(1.0,1.0,1.0,1.0); 9 | } 10 | void MyWidget::resizeGL(int width,int height){ 11 | glViewport(0,0,width,height); 12 | 13 | glMatrixMode(GL_PROJECTION); 14 | } 15 | void MyWidget::paintGL(){ 16 | glClear(GL_COLOR_BUFFER_BIT); 17 | glBegin(GL_POLYGON); 18 | glColor3d(1.0,0.5,0.5); 19 | glVertex2f(0,0); 20 | glVertex2f(0.5,0); 21 | glVertex2f(0.5,0.5); 22 | glVertex2f(0.25,0.25); 23 | glVertex2f(0,0.5); 24 | glEnd(); 25 | /* 26 | // draw data 27 | for(auto layer:map->LAYERS){ 28 | Style gl_style; 29 | gl_style=layer.layer_style; 30 | for(auto feature:layer.features){ 31 | if(feature.feature_type==1){ 32 | // draw line 33 | glLineWidth(gl_style.lineWidth); 34 | glBegin(GL_LINE_STRIP); 35 | int red =gl_style.lineColor.Red; 36 | int green=gl_style.lineColor.Green; 37 | int blue=gl_style.lineColor.Blue; 38 | glColor3d(1.0*red/255,1.0*green/255,1.0*blue/255); 39 | for(auto pt:feature.pts){ 40 | glVertex2f(xy2screen(pt).x,xy2screen(pt).y); 41 | } 42 | glEnd(); 43 | } 44 | if(feature.feature_type==2){ 45 | // draw polygon 46 | glPolygonMode(GL_FRONT,GL_FILL); 47 | glBegin(GL_POLYGON); 48 | int red =gl_style.polyColor.Red; 49 | int green=gl_style.polyColor.Green; 50 | int blue=gl_style.polyColor.Blue; 51 | glColor3d(1.0*red/255,1.0*green/255,1.0*blue/255); 52 | for(auto pt:feature.pts){ 53 | glVertex2f(xy2screen(pt).x,xy2screen(pt).y); 54 | } 55 | glEnd(); 56 | } 57 | } 58 | } 59 | */ 60 | glFlush(); 61 | } 62 | Point MyWidget::xy2screen(Point pt){ 63 | // transfer point to screen coordinate 64 | double width=this->map->right-this->map->left; 65 | double height=this->map->top-this->map->bottom; 66 | Point screen; 67 | screen.x=(pt.x-this->map->left)/width*2-1; 68 | screen.y=(pt.y-this->map->bottom)/height*2-1; 69 | return screen; 70 | } 71 | void MyWidget::mousePressEvent(QMouseEvent *event){ 72 | // mouse click 73 | double x,y; 74 | x=event->x(); 75 | y=event->y(); 76 | double width=this->map->right-this->map->left; 77 | double height=this->map->top-this->map->bottom; 78 | double window_width=this->width(); 79 | double window_height=this->height(); 80 | double real_x,real_y; 81 | real_x=x/window_width*width+this->map->left; 82 | real_y=y/window_height*height+this->map->bottom; 83 | } 84 | -------------------------------------------------------------------------------- /mywidget.cpp.autosave: -------------------------------------------------------------------------------- 1 | #include "mywidget.h" 2 | 3 | MyWidget::MyWidget() 4 | { 5 | 6 | } 7 | void MyWidget::initializeGL(){ 8 | glClearColor(1.0,1.0,1.0,1.0); 9 | } 10 | void MyWidget::resizeGL(int width,int height){ 11 | glViewport(0,0,width,height); 12 | 13 | glMatrixMode(GL_PROJECTION); 14 | } 15 | void MyWidget::paintGL(){ 16 | glClear(GL_COLOR_BUFFER_BIT); 17 | /* 18 | glBegin(GL_POLYGON); 19 | glColor3d(1.0,0.5,0.5); 20 | glVertex2f(0,0); 21 | glVertex2f(0.5,0); 22 | glVertex2f(0.5,0.5); 23 | glVertex2f(0.25,0.25); 24 | glVertex2f(0,0.5); 25 | glEnd(); 26 | */ 27 | // draw data 28 | for(auto layer:map->LAYERS){ 29 | Style gl_style; 30 | gl_style=layer.layer_style; 31 | for(auto feature:layer.features){ 32 | if(feature.feature_type==1){ 33 | // draw line 34 | glLineWidth(gl_style.lineWidth); 35 | glBegin(GL_LINE_STRIP); 36 | int red =gl_style.lineColor.Red; 37 | int green=gl_style.lineColor.Green; 38 | int blue=gl_style.lineColor.Blue; 39 | glColor3d(1.0*red/255,1.0*green/255,1.0*blue/255); 40 | for(auto pt:feature.pts){ 41 | glVertex2f(xy2screen(pt).x,xy2screen(pt).y); 42 | } 43 | glEnd(); 44 | } 45 | if(feature.feature_type==2){ 46 | // draw polygon 47 | glPolygonMode(GL_FRONT,GL_FILL); 48 | glBegin(GL_POLYGON); 49 | int red =gl_style.polyColor.Red; 50 | int green=gl_style.polyColor.Green; 51 | int blue=gl_style.polyColor.Blue; 52 | glColor3d(1.0*red/255,1.0*green/255,1.0*blue/255); 53 | for(auto pt:feature.pts){ 54 | glVertex2f(xy2screen(pt).x,xy2screen(pt).y); 55 | } 56 | glEnd(); 57 | } 58 | } 59 | } 60 | glFlush(); 61 | } 62 | 63 | void MyWidget::DrawTest(){ 64 | } 65 | Point MyWidget::xy2screen(Point pt){ 66 | // transfer point to screen coordinate 67 | double width=this->map->right-this->map->left; 68 | double height=this->map->top-this->map->bottom; 69 | Point screen; 70 | screen.x=(pt.x-this->map->left)/width*2-1; 71 | screen.y=(pt.y-this->map->bottom)/height*2-1; 72 | return screen; 73 | } 74 | void MyWidget::mousePressEvent(QMouseEvent *event){ 75 | // mouse click 76 | double x,y; 77 | x=event->x(); 78 | y=event->y(); 79 | double width=this->map->right-this->map->left; 80 | double height=this->map->top-this->map->bottom; 81 | double window_width=this->width(); 82 | double window_height=this->height(); 83 | double real_x,real_y; 84 | real_x=x/window_width*width+this->map->left; 85 | real_y=y/window_height*height+this->map->bottom; 86 | } 87 | -------------------------------------------------------------------------------- /mywidget.h: -------------------------------------------------------------------------------- 1 | #ifndef MYWIDGET_H 2 | #define MYWIDGET_H 3 | #include "QGLWidget" 4 | #include "qgl.h" 5 | #include "map.h" 6 | #include "layer.h" 7 | #include "style.h" 8 | #include 9 | 10 | class MyWidget : public QGLWidget 11 | { 12 | public: 13 | MyWidget(); 14 | Map *map; 15 | void initializeGL(); 16 | void paintGL(); 17 | void resizeGL(int width,int height); 18 | Point xy2screen(Point pt); 19 | void mousePressEvent(QMouseEvent *event); 20 | }; 21 | 22 | #endif // MYWIDGET_H 23 | -------------------------------------------------------------------------------- /mywidget.h.autosave: -------------------------------------------------------------------------------- 1 | #ifndef MYWIDGET_H 2 | #define MYWIDGET_H 3 | #include "QGLWidget" 4 | #include "qgl.h" 5 | #include "map.h" 6 | #include "layer.h" 7 | #include "style.h" 8 | #include 9 | #include 10 | #include 11 | 12 | class MyWidget : public QGLWidget 13 | { 14 | public: 15 | MyWidget(); 16 | Map *map; 17 | void initializeGL(); 18 | void paintGL(); 19 | void resizeGL(int width,int height); 20 | Point xy2screen(Point pt); 21 | void DrawTest(); 22 | void mousePressEvent(QMouseEvent *event); 23 | }; 24 | 25 | #endif // MYWIDGET_H 26 | -------------------------------------------------------------------------------- /opengl1.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2017-12-15T16:22:37 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui opengl 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = opengl1 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which has been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | 26 | SOURCES += \ 27 | main.cpp \ 28 | widget.cpp \ 29 | mywidget.cpp \ 30 | layer.cpp \ 31 | map.cpp \ 32 | geofile.cpp \ 33 | point.cpp \ 34 | feature.cpp \ 35 | stylefile.cpp \ 36 | style.cpp \ 37 | color.cpp 38 | 39 | HEADERS += \ 40 | widget.h \ 41 | mywidget.h \ 42 | layer.h \ 43 | map.h \ 44 | geofile.h \ 45 | point.h \ 46 | feature.h \ 47 | stylefile.h \ 48 | style.h \ 49 | color.h 50 | 51 | FORMS += \ 52 | widget.ui 53 | -------------------------------------------------------------------------------- /opengl1.pro.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | EnvironmentId 7 | {6e245d1b-773b-42b6-bc3b-9bc3996420a2} 8 | 9 | 10 | ProjectExplorer.Project.ActiveTarget 11 | 0 12 | 13 | 14 | ProjectExplorer.Project.EditorSettings 15 | 16 | true 17 | false 18 | true 19 | 20 | Cpp 21 | 22 | CppGlobal 23 | 24 | 25 | 26 | QmlJS 27 | 28 | QmlJSGlobal 29 | 30 | 31 | 2 32 | UTF-8 33 | false 34 | 4 35 | false 36 | 80 37 | true 38 | true 39 | 1 40 | true 41 | false 42 | 0 43 | true 44 | true 45 | 0 46 | 8 47 | true 48 | 1 49 | true 50 | true 51 | true 52 | false 53 | 54 | 55 | 56 | ProjectExplorer.Project.PluginSettings 57 | 58 | 59 | 60 | ProjectExplorer.Project.Target.0 61 | 62 | Desktop Qt 5.10.0 GCC 64bit 63 | Desktop Qt 5.10.0 GCC 64bit 64 | qt.qt5.5100.gcc_64_kit 65 | 0 66 | 0 67 | 0 68 | 69 | /home/kyh/Documents/Qt/build-opengl1-Desktop_Qt_5_10_0_GCC_64bit-Debug 70 | 71 | 72 | true 73 | qmake 74 | 75 | QtProjectManager.QMakeBuildStep 76 | true 77 | 78 | false 79 | false 80 | false 81 | 82 | 83 | true 84 | Make 85 | 86 | Qt4ProjectManager.MakeStep 87 | 88 | -w 89 | -r 90 | 91 | false 92 | 93 | 94 | 95 | 2 96 | Build 97 | 98 | ProjectExplorer.BuildSteps.Build 99 | 100 | 101 | 102 | true 103 | Make 104 | 105 | Qt4ProjectManager.MakeStep 106 | 107 | -w 108 | -r 109 | 110 | true 111 | clean 112 | 113 | 114 | 1 115 | Clean 116 | 117 | ProjectExplorer.BuildSteps.Clean 118 | 119 | 2 120 | false 121 | 122 | Debug 123 | 124 | Qt4ProjectManager.Qt4BuildConfiguration 125 | 2 126 | true 127 | 128 | 129 | /home/kyh/Documents/Qt/build-opengl1-Desktop_Qt_5_10_0_GCC_64bit-Release 130 | 131 | 132 | true 133 | qmake 134 | 135 | QtProjectManager.QMakeBuildStep 136 | false 137 | 138 | false 139 | false 140 | false 141 | 142 | 143 | true 144 | Make 145 | 146 | Qt4ProjectManager.MakeStep 147 | 148 | -w 149 | -r 150 | 151 | false 152 | 153 | 154 | 155 | 2 156 | Build 157 | 158 | ProjectExplorer.BuildSteps.Build 159 | 160 | 161 | 162 | true 163 | Make 164 | 165 | Qt4ProjectManager.MakeStep 166 | 167 | -w 168 | -r 169 | 170 | true 171 | clean 172 | 173 | 174 | 1 175 | Clean 176 | 177 | ProjectExplorer.BuildSteps.Clean 178 | 179 | 2 180 | false 181 | 182 | Release 183 | 184 | Qt4ProjectManager.Qt4BuildConfiguration 185 | 0 186 | true 187 | 188 | 189 | /home/kyh/Documents/Qt/build-opengl1-Desktop_Qt_5_10_0_GCC_64bit-Profile 190 | 191 | 192 | true 193 | qmake 194 | 195 | QtProjectManager.QMakeBuildStep 196 | true 197 | 198 | false 199 | true 200 | false 201 | 202 | 203 | true 204 | Make 205 | 206 | Qt4ProjectManager.MakeStep 207 | 208 | -w 209 | -r 210 | 211 | false 212 | 213 | 214 | 215 | 2 216 | Build 217 | 218 | ProjectExplorer.BuildSteps.Build 219 | 220 | 221 | 222 | true 223 | Make 224 | 225 | Qt4ProjectManager.MakeStep 226 | 227 | -w 228 | -r 229 | 230 | true 231 | clean 232 | 233 | 234 | 1 235 | Clean 236 | 237 | ProjectExplorer.BuildSteps.Clean 238 | 239 | 2 240 | false 241 | 242 | Profile 243 | 244 | Qt4ProjectManager.Qt4BuildConfiguration 245 | 0 246 | true 247 | 248 | 3 249 | 250 | 251 | 0 252 | Deploy 253 | 254 | ProjectExplorer.BuildSteps.Deploy 255 | 256 | 1 257 | Deploy locally 258 | 259 | ProjectExplorer.DefaultDeployConfiguration 260 | 261 | 1 262 | 263 | 264 | false 265 | false 266 | 1000 267 | 268 | true 269 | 270 | false 271 | false 272 | false 273 | false 274 | true 275 | 0.01 276 | 10 277 | true 278 | 1 279 | 25 280 | 281 | 1 282 | true 283 | false 284 | true 285 | valgrind 286 | 287 | 0 288 | 1 289 | 2 290 | 3 291 | 4 292 | 5 293 | 6 294 | 7 295 | 8 296 | 9 297 | 10 298 | 11 299 | 12 300 | 13 301 | 14 302 | 303 | 2 304 | 305 | opengl1 306 | 307 | Qt4ProjectManager.Qt4RunConfiguration:/home/kyh/Documents/Qt/opengl1/opengl1.pro 308 | true 309 | 310 | opengl1.pro 311 | false 312 | 313 | /home/kyh/Documents/Qt/build-opengl1-Desktop_Qt_5_10_0_GCC_64bit-Debug 314 | 3768 315 | false 316 | true 317 | false 318 | false 319 | true 320 | 321 | 1 322 | 323 | 324 | 325 | ProjectExplorer.Project.TargetCount 326 | 1 327 | 328 | 329 | ProjectExplorer.Project.Updater.FileVersion 330 | 18 331 | 332 | 333 | Version 334 | 18 335 | 336 | 337 | -------------------------------------------------------------------------------- /point.cpp: -------------------------------------------------------------------------------- 1 | #include "point.h" 2 | 3 | Point::Point() 4 | { 5 | 6 | } 7 | 8 | bool Point::LoadPoint(QTextStream *textStream,Point *pt){ 9 | QString line=textStream->readLine() ; 10 | double x,y; 11 | x=line.split(',')[0].toDouble(); 12 | y=line.split(',')[1].toDouble(); 13 | pt->x=x; 14 | pt->y=y; 15 | if(x==-99999&&y==-99999){ 16 | return false; 17 | } 18 | return true; 19 | } 20 | 21 | void Point::DrawPoint(){ 22 | 23 | } 24 | -------------------------------------------------------------------------------- /point.h: -------------------------------------------------------------------------------- 1 | #ifndef POINT_H 2 | #define POINT_H 3 | #include 4 | #include 5 | 6 | class Point 7 | { 8 | public: 9 | Point(); 10 | double x,y; 11 | bool LoadPoint(QTextStream* textStream,Point* pt); 12 | void DrawPoint(); 13 | }; 14 | 15 | #endif // POINT_H 16 | -------------------------------------------------------------------------------- /style.cpp: -------------------------------------------------------------------------------- 1 | #include "style.h" 2 | 3 | Style::Style() 4 | { 5 | lineExist=0;polyExist=0;lineWidth=0; 6 | } 7 | 8 | void Style::LoadStyle(QTextStream *textStream){ 9 | lineExist= textStream->readLine().toInt(); 10 | if(lineExist==1){ 11 | lineWidth=textStream->readLine().toDouble(); 12 | QString color=textStream->readLine(); 13 | lineColor.LoadColor(color); 14 | } 15 | polyExist=textStream->readLine().toInt(); 16 | if(polyExist==1){ 17 | QString color=textStream->readLine(); 18 | polyColor.LoadColor(color); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /style.h: -------------------------------------------------------------------------------- 1 | #ifndef STYLE_H 2 | #define STYLE_H 3 | #include 4 | #include 5 | #include "color.h" 6 | 7 | class Style 8 | { 9 | public: 10 | Style(); 11 | int lineExist,polyExist; 12 | double lineWidth; 13 | Color lineColor,polyColor; 14 | void LoadStyle(QTextStream *textStream); 15 | }; 16 | 17 | #endif // STYLE_H 18 | -------------------------------------------------------------------------------- /stylefile.cpp: -------------------------------------------------------------------------------- 1 | #include "stylefile.h" 2 | 3 | StyleFile::StyleFile() 4 | { 5 | 6 | } 7 | 8 | void StyleFile::LoadStyle(QString filePath){ 9 | QFile file(filePath); 10 | file.open(QIODevice::ReadOnly); 11 | QTextStream textStream(&file); 12 | 13 | map->LoadStyle(&textStream); 14 | file.close(); 15 | } 16 | -------------------------------------------------------------------------------- /stylefile.h: -------------------------------------------------------------------------------- 1 | #ifndef STYLEFILE_H 2 | #define STYLEFILE_H 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "map.h" 9 | #include "layer.h" 10 | 11 | class StyleFile 12 | { 13 | public: 14 | StyleFile(); 15 | Map *map; 16 | 17 | void LoadStyle(QString filePath); 18 | }; 19 | 20 | #endif // STYLEFILE_H 21 | -------------------------------------------------------------------------------- /widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include "ui_widget.h" 3 | 4 | Widget::Widget(QWidget *parent) : 5 | QWidget(parent), 6 | ui(new Ui::Widget) 7 | { 8 | ui->setupUi(this); 9 | } 10 | 11 | Widget::~Widget() 12 | { 13 | delete ui; 14 | } 15 | -------------------------------------------------------------------------------- /widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class Widget; 8 | } 9 | 10 | class Widget : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit Widget(QWidget *parent = 0); 16 | ~Widget(); 17 | 18 | private: 19 | Ui::Widget *ui; 20 | }; 21 | 22 | #endif // WIDGET_H 23 | -------------------------------------------------------------------------------- /widget.ui: -------------------------------------------------------------------------------- 1 | 2 | Widget 3 | 4 | 5 | 6 | 0 7 | 0 8 | 400 9 | 300 10 | 11 | 12 | 13 | Widget 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | --------------------------------------------------------------------------------