Grid::Grid(int newGridWidth, int newCentreX, int newCentreY, int newCellWidth, int newCellHeight): gridWidth( newGridWidth ), cellWidth( newCellWidth ), cellHeight( newCellHeight ) { // If gridWidth is odd, gridWidth%2 allows additional half-width shift to centre central socket gridBound.x = (int)(newCentreX-(cellWidth*(gridWidth*0.5))) - (int)((gridWidth%2) * (cellWidth*0.5)); gridBound.y = (int)(newCentreY-(cellHeight*(gridWidth*0.5))) - (int)((gridWidth%2) * (cellHeight*0.5)); gridBound.w = gridWidth * cellWidth; gridBound.h = gridWidth * cellHeight; // Allocate the number of elements required generateSockets(); populateSockets(); }
void EventMachineThread::readEvents() { QTcpSocket* client = (QTcpSocket*) sender(); qDebug() << "input xml file"; QDomDocument doc("module"); QTextStream inSocket(client); QString xmlData; xmlData = inSocket.readAll(); int errorLine; QString errorParse; if (!doc.setContent(xmlData, &errorParse, &errorLine)) { qDebug() << "Error: " << errorParse; qDebug() << "in line: " << errorLine << endl; return; } QDomElement docElem = doc.documentElement(); QVector<Connector*>::iterator connect = m_connections.begin(); QDomNode n = docElem.firstChild(); while(!n.isNull()) { QDomElement e = n.toElement(); // пробуем преобразовать узел в элемент. if(!e.isNull()) { int idModule = e.attribute("id").toInt(); if (idModule) { // удобнее это вынести в функцию for (connect = m_connections.begin(); connect != m_connections.end(); ++connect) { if ((*connect)->idModule == idModule) { (*connect)->parseXml(e); } } } } n = n.nextSibling(); } // now it there, maybe this mast be in other place generateSockets(); }