Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Q_DECL_CONSTEXPR inline int QSize::height() const
- { return ht; }
- qDebug() << QString("---SETTINGS DEBUG---")+QString("rn")<<
- "netProcPage: "+netProcPage.url()+"rn" <<
- "mapSize.width(): "+QString::number(mapSize.width())+"rn"<<
- "mapSize.height(): "+QString::number(mapSize.height())+"rn"<<
- "mapZoom: "+QString::number(mapZoom)+"rn"<<
- "mappxSize.width(): "+QString::number(mappxSize.width())+"rn"<<
- "mappxSize.height(): "+QString::number(mappxSize.height())+"rn"<<
- "UserCoords[0]: "+QString::number(UserCoords[0])+"rn"<<
- "UserCoords[1]: "+QString::number(UserCoords[1])+"rn"<<
- "mapCoordOffsets[0]: "+QString::number(mapCoordOffsets[0])+"rn"<<
- "mapCoordOffsets[1]: "+QString::number(mapCoordOffsets[1])+"rn"<<
- "getWindowSize.width(): "+QString::number(getWindowSize.width())+"rn"<<
- "getWindowSize.height(): "+QString::number(getWindowSize.height())+"rn"<<
- "mappxOffsets[0]: "+QString::number(mappxOffsets[0])+"rn"<<
- "mappxOffsets[1]: "+QString::number(mappxOffsets[1])+"rn"<<
- QString("---END SETTINGS DEBUG---")+QString("rn");
- mkeMap.genMap(QString("Map1"), tempmapSize, tempmapZoom, mapDisp->ui);
- QSize tempmapSize;
- tempmapSize = settings->mapSize; //<--- The error might be coming from here, is there an alternative?
- #include "settings.h"
- Settings::Settings(QWidget *parent)
- {
- netProcPage = "http://localhost:81";
- // Max image size is 32767x32767 pixels (divided by 4*mapZoom since 4 panes are used at mapZoom zoom)
- // If max mapZoom is 20, max size of map is 409x409, or 408x408 to keep it even
- mapSize.setWidth(250);
- mapSize.setHeight(250);
- mapZoom = 10;
- mappxSize.setWidth(mapSize.width()*mapZoom);
- mappxSize.setHeight(mapSize.height()*mapZoom);
- //downloadMap(netProcPage,"getMap","Username","Password");
- //makeMap("bingbong",mapSize,mapZoom);
- UserCoords[0] = 0;
- UserCoords[1] = 0;
- mapCoordOffsets[0] = UserCoords[0] + .5 * mapSize.width();
- mapCoordOffsets[1] = UserCoords[1] + .5 * mapSize.height();
- //getWindowSize.setWidth(parent->width());
- //getWindowSize.setHeight(parent->height());
- getWindowSize.setWidth(500);
- getWindowSize.setHeight(500);
- mappxOffsets[0] = UserCoords[0]*mapZoom + .5 * getWindowSize.width() - .5 * mappxSize.width();
- mappxOffsets[1] = UserCoords[1]*mapZoom + .5 * getWindowSize.height() - .5 * mappxSize.height();
- }
- void Settings::debug()
- {
- qDebug() << QString("---SETTINGS DEBUG---")+QString("rn")<<
- "netProcPage: "+netProcPage.url()+"rn" <<
- "mapSize.width(): "+QString::number(mapSize.width())+"rn"<<
- "mapSize.height(): "+QString::number(mapSize.height())+"rn"<<
- "mapZoom: "+QString::number(mapZoom)+"rn"<<
- "mappxSize.width(): "+QString::number(mappxSize.width())+"rn"<<
- "mappxSize.height(): "+QString::number(mappxSize.height())+"rn"<<
- "UserCoords[0]: "+QString::number(UserCoords[0])+"rn"<<
- "UserCoords[1]: "+QString::number(UserCoords[1])+"rn"<<
- "mapCoordOffsets[0]: "+QString::number(mapCoordOffsets[0])+"rn"<<
- "mapCoordOffsets[1]: "+QString::number(mapCoordOffsets[1])+"rn"<<
- "getWindowSize.width(): "+QString::number(getWindowSize.width())+"rn"<<
- "getWindowSize.height(): "+QString::number(getWindowSize.height())+"rn";//<<
- //"mappxOffsets[0]: "+QString::number(mappxOffsets[0])+"rn"<<
- //"mappxOffsets[1]: "+QString::number(mappxOffsets[1])+"rn"<<
- //QString("---END SETTINGS DEBUG---")+QString("rn");
- }
- QSize* Settings::getmapSize()
- {
- return &mapSize;
- }
- int Settings::getmapZoom()
- {
- return mapZoom;
- }
- void makeMap::genMap(QString name, QPointF* inSize, int* zoom, Ui::MapDisp* ui)
- {
- QVector<QString> mapvector;
- QPointF mapSize = *inSize; // <--- The problem is right here
- ...
- }
- QPointF* tempmapSize;
- tempmapSize = settings->getmapSize();
- int* tempmapZoom = settings->getmapZoom();
- mkeMap.genMap(QString("Map1"), tempmapSize, tempmapZoom, mapDisp->ui);
- Starting C:program-debug.exe...
- ASSERT failure in QVector<T>::operator[]: "index out of range", file ../../../../../Qt/5.2.0/mingw48_32/include/QtCore/qvector.h, line 369
- Invalid parameter passed to C runtime function.
- Invalid parameter passed to C runtime function.
- C:program-debug.exe exited with code 3
- void makeMap::genMap(QString name, QPointF* inSize, int* zoom, Ui::MapDisp* ui)
- {
- QVector<QString> mapvector;
- QPointF mapSize = *inSize; //<---Here's the segmentation fault
- /* Using this instead of the above works, as well as replacing zoom which causes another segmentation fault when dereferenced
- QPointF mapSize;
- mapSize.setX(250);
- mapSize.setY(250);
- int zoom0 = 10;
- */
- QFile file(name+"_"+QString::number(mapSize.x())+"x"+QString::number(mapSize.y())+".rtsmap");
- file.open(QIODevice::WriteOnly | QIODevice::Text);
- QTextStream out(&file);
- mapvector.resize(mapSize.x() * mapSize.y());
- for(int x = 0; x < mapSize.x(); x++){
- for(int y = 0; y < mapSize.y(); y++){
- uint decimalcolor = (((qSin(x)+1) + (qSin(y)+1))/4)>1?16777215:(((qSin(x)+1) + (qSin(y)+1))/4)*16777214;
- QString hexadecimalcolor;
- hexadecimalcolor.setNum(decimalcolor,16);
- mapvector[index(x, y, mapSize)] = "#" + hexadecimalcolor;
- //drawRect(x*10,y*10,10,10,"#"+hexadecimalcolor,zoom);
- out << "#" << hexadecimalcolor+'n';
- }
- }
- file.close();
- drawMap(mapvector,zoom0,ui,mapSize);
- }
- MapCtrl::MapCtrl(QWidget *parent, Settings *settingsIn) :
- QWidget(parent),
- ui(new Ui::MapCtrl)
- {
- ui->setupUi(this);
- mapDisp = new MapDisp(parent, settingsIn);
- addMap();
- settings = settingsIn;
- }
- MainWindow::MainWindow(QWidget *parent) :
- QMainWindow(parent),
- ui(new Ui::MainWindow)
- {
- ui->setupUi(this);
- wScr = new WelcomeScreen(this);
- Settings *settings = new Settings(this);
- mapCtrl = new MapCtrl(parent,settings);
- ...
- }
- MapCtrl::MapCtrl(QWidget *parent, Settings *settingsIn) :
- QWidget(parent),
- ui(new Ui::MapCtrl)
- {
- ui->setupUi(this);
- mapDisp = new MapDisp(parent, settingsIn);
- addMap();
- qDebug() << "bingbong!!" << settingsIn->mapSize.x();
- settings = settingsIn;
- }
- MapCtrl::MapCtrl(QWidget *parent, Settings *settingsIn) :
- QWidget(parent),
- ui(new Ui::MapCtrl)
- {
- ui->setupUi(this);
- mapDisp = new MapDisp(parent, settingsIn);
- qDebug() << "bingbong!!" << settingsIn->mapSize.x();
- settings = settingsIn;
- addMap();
- }
- QSize Settings::getmapSize() const
- {
- return mapSize;
- }
- mapCoordOffsets = UserCoords + (toPoint(mapSize) * .5);
- static QPointF toPoint(const QSize & size) {
- return QPointF(size.width(), size.height());
- }
- void makeMap::genMap(..., QPointF* inSize, int* zoom, ...)
- MapParams makeMap::genMap(...);
- MapParams makeMap::genMap(..., MapParams params) {
- ...
- params.size = ...;
- params.zoom = ...;
- ...
- return params;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement