Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.08 KB | None | 0 0
  1. Q_DECL_CONSTEXPR inline int QSize::height() const
  2. { return ht; }
  3.  
  4. qDebug() << QString("---SETTINGS DEBUG---")+QString("rn")<<
  5. "netProcPage: "+netProcPage.url()+"rn" <<
  6. "mapSize.width(): "+QString::number(mapSize.width())+"rn"<<
  7. "mapSize.height(): "+QString::number(mapSize.height())+"rn"<<
  8. "mapZoom: "+QString::number(mapZoom)+"rn"<<
  9. "mappxSize.width(): "+QString::number(mappxSize.width())+"rn"<<
  10. "mappxSize.height(): "+QString::number(mappxSize.height())+"rn"<<
  11. "UserCoords[0]: "+QString::number(UserCoords[0])+"rn"<<
  12. "UserCoords[1]: "+QString::number(UserCoords[1])+"rn"<<
  13. "mapCoordOffsets[0]: "+QString::number(mapCoordOffsets[0])+"rn"<<
  14. "mapCoordOffsets[1]: "+QString::number(mapCoordOffsets[1])+"rn"<<
  15. "getWindowSize.width(): "+QString::number(getWindowSize.width())+"rn"<<
  16. "getWindowSize.height(): "+QString::number(getWindowSize.height())+"rn"<<
  17. "mappxOffsets[0]: "+QString::number(mappxOffsets[0])+"rn"<<
  18. "mappxOffsets[1]: "+QString::number(mappxOffsets[1])+"rn"<<
  19. QString("---END SETTINGS DEBUG---")+QString("rn");
  20.  
  21. mkeMap.genMap(QString("Map1"), tempmapSize, tempmapZoom, mapDisp->ui);
  22.  
  23. QSize tempmapSize;
  24. tempmapSize = settings->mapSize; //<--- The error might be coming from here, is there an alternative?
  25.  
  26. #include "settings.h"
  27.  
  28. Settings::Settings(QWidget *parent)
  29. {
  30.  
  31. netProcPage = "http://localhost:81";
  32.  
  33. // Max image size is 32767x32767 pixels (divided by 4*mapZoom since 4 panes are used at mapZoom zoom)
  34. // If max mapZoom is 20, max size of map is 409x409, or 408x408 to keep it even
  35. mapSize.setWidth(250);
  36. mapSize.setHeight(250);
  37.  
  38. mapZoom = 10;
  39. mappxSize.setWidth(mapSize.width()*mapZoom);
  40. mappxSize.setHeight(mapSize.height()*mapZoom);
  41.  
  42. //downloadMap(netProcPage,"getMap","Username","Password");
  43. //makeMap("bingbong",mapSize,mapZoom);
  44. UserCoords[0] = 0;
  45. UserCoords[1] = 0;
  46. mapCoordOffsets[0] = UserCoords[0] + .5 * mapSize.width();
  47. mapCoordOffsets[1] = UserCoords[1] + .5 * mapSize.height();
  48. //getWindowSize.setWidth(parent->width());
  49. //getWindowSize.setHeight(parent->height());
  50. getWindowSize.setWidth(500);
  51. getWindowSize.setHeight(500);
  52. mappxOffsets[0] = UserCoords[0]*mapZoom + .5 * getWindowSize.width() - .5 * mappxSize.width();
  53. mappxOffsets[1] = UserCoords[1]*mapZoom + .5 * getWindowSize.height() - .5 * mappxSize.height();
  54. }
  55.  
  56. void Settings::debug()
  57. {
  58. qDebug() << QString("---SETTINGS DEBUG---")+QString("rn")<<
  59. "netProcPage: "+netProcPage.url()+"rn" <<
  60. "mapSize.width(): "+QString::number(mapSize.width())+"rn"<<
  61. "mapSize.height(): "+QString::number(mapSize.height())+"rn"<<
  62. "mapZoom: "+QString::number(mapZoom)+"rn"<<
  63. "mappxSize.width(): "+QString::number(mappxSize.width())+"rn"<<
  64. "mappxSize.height(): "+QString::number(mappxSize.height())+"rn"<<
  65. "UserCoords[0]: "+QString::number(UserCoords[0])+"rn"<<
  66. "UserCoords[1]: "+QString::number(UserCoords[1])+"rn"<<
  67. "mapCoordOffsets[0]: "+QString::number(mapCoordOffsets[0])+"rn"<<
  68. "mapCoordOffsets[1]: "+QString::number(mapCoordOffsets[1])+"rn"<<
  69. "getWindowSize.width(): "+QString::number(getWindowSize.width())+"rn"<<
  70. "getWindowSize.height(): "+QString::number(getWindowSize.height())+"rn";//<<
  71. //"mappxOffsets[0]: "+QString::number(mappxOffsets[0])+"rn"<<
  72. //"mappxOffsets[1]: "+QString::number(mappxOffsets[1])+"rn"<<
  73. //QString("---END SETTINGS DEBUG---")+QString("rn");
  74. }
  75.  
  76. QSize* Settings::getmapSize()
  77. {
  78. return &mapSize;
  79. }
  80.  
  81. int Settings::getmapZoom()
  82. {
  83. return mapZoom;
  84. }
  85.  
  86. void makeMap::genMap(QString name, QPointF* inSize, int* zoom, Ui::MapDisp* ui)
  87. {
  88. QVector<QString> mapvector;
  89. QPointF mapSize = *inSize; // <--- The problem is right here
  90.  
  91. ...
  92. }
  93.  
  94. QPointF* tempmapSize;
  95. tempmapSize = settings->getmapSize();
  96. int* tempmapZoom = settings->getmapZoom();
  97. mkeMap.genMap(QString("Map1"), tempmapSize, tempmapZoom, mapDisp->ui);
  98.  
  99. Starting C:program-debug.exe...
  100. ASSERT failure in QVector<T>::operator[]: "index out of range", file ../../../../../Qt/5.2.0/mingw48_32/include/QtCore/qvector.h, line 369
  101. Invalid parameter passed to C runtime function.
  102. Invalid parameter passed to C runtime function.
  103. C:program-debug.exe exited with code 3
  104.  
  105. void makeMap::genMap(QString name, QPointF* inSize, int* zoom, Ui::MapDisp* ui)
  106. {
  107. QVector<QString> mapvector;
  108. QPointF mapSize = *inSize; //<---Here's the segmentation fault
  109. /* Using this instead of the above works, as well as replacing zoom which causes another segmentation fault when dereferenced
  110. QPointF mapSize;
  111. mapSize.setX(250);
  112. mapSize.setY(250);
  113. int zoom0 = 10;
  114. */
  115.  
  116. QFile file(name+"_"+QString::number(mapSize.x())+"x"+QString::number(mapSize.y())+".rtsmap");
  117. file.open(QIODevice::WriteOnly | QIODevice::Text);
  118. QTextStream out(&file);
  119. mapvector.resize(mapSize.x() * mapSize.y());
  120. for(int x = 0; x < mapSize.x(); x++){
  121. for(int y = 0; y < mapSize.y(); y++){
  122. uint decimalcolor = (((qSin(x)+1) + (qSin(y)+1))/4)>1?16777215:(((qSin(x)+1) + (qSin(y)+1))/4)*16777214;
  123. QString hexadecimalcolor;
  124. hexadecimalcolor.setNum(decimalcolor,16);
  125. mapvector[index(x, y, mapSize)] = "#" + hexadecimalcolor;
  126. //drawRect(x*10,y*10,10,10,"#"+hexadecimalcolor,zoom);
  127. out << "#" << hexadecimalcolor+'n';
  128. }
  129. }
  130. file.close();
  131. drawMap(mapvector,zoom0,ui,mapSize);
  132. }
  133.  
  134. MapCtrl::MapCtrl(QWidget *parent, Settings *settingsIn) :
  135. QWidget(parent),
  136. ui(new Ui::MapCtrl)
  137. {
  138. ui->setupUi(this);
  139. mapDisp = new MapDisp(parent, settingsIn);
  140. addMap();
  141. settings = settingsIn;
  142. }
  143.  
  144. MainWindow::MainWindow(QWidget *parent) :
  145. QMainWindow(parent),
  146. ui(new Ui::MainWindow)
  147. {
  148. ui->setupUi(this);
  149. wScr = new WelcomeScreen(this);
  150. Settings *settings = new Settings(this);
  151. mapCtrl = new MapCtrl(parent,settings);
  152. ...
  153. }
  154.  
  155. MapCtrl::MapCtrl(QWidget *parent, Settings *settingsIn) :
  156. QWidget(parent),
  157. ui(new Ui::MapCtrl)
  158. {
  159. ui->setupUi(this);
  160. mapDisp = new MapDisp(parent, settingsIn);
  161. addMap();
  162. qDebug() << "bingbong!!" << settingsIn->mapSize.x();
  163. settings = settingsIn;
  164.  
  165. }
  166.  
  167. MapCtrl::MapCtrl(QWidget *parent, Settings *settingsIn) :
  168. QWidget(parent),
  169. ui(new Ui::MapCtrl)
  170. {
  171. ui->setupUi(this);
  172. mapDisp = new MapDisp(parent, settingsIn);
  173.  
  174. qDebug() << "bingbong!!" << settingsIn->mapSize.x();
  175. settings = settingsIn;
  176. addMap();
  177. }
  178.  
  179. QSize Settings::getmapSize() const
  180. {
  181. return mapSize;
  182. }
  183.  
  184. mapCoordOffsets = UserCoords + (toPoint(mapSize) * .5);
  185.  
  186. static QPointF toPoint(const QSize & size) {
  187. return QPointF(size.width(), size.height());
  188. }
  189.  
  190. void makeMap::genMap(..., QPointF* inSize, int* zoom, ...)
  191.  
  192. MapParams makeMap::genMap(...);
  193.  
  194. MapParams makeMap::genMap(..., MapParams params) {
  195. ...
  196. params.size = ...;
  197. params.zoom = ...;
  198. ...
  199. return params;
  200. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement