PublisherDialog::PublisherDialog(QWidget *parent) : QMainWindow(parent), ui(new Ui::PublisherDialog), publisher(0) { ui->setupUi(this); #if defined(Q_OS_SYMBIAN) || defined(Q_WS_SIMULATOR) QPushButton* button = ui->buttonBox->button(QDialogButtonBox::Close); if (button) { ui->buttonBox->removeButton(button); } QPushButton *switchButton = ui->buttonBox->addButton(tr("Switch"), QDialogButtonBox::ActionRole); connect(switchButton, SIGNAL(clicked()), this, SIGNAL(switchRequested())); #elif defined(MEEGO_EDITION_HARMATTAN) connect(ui->buttonBox->button(QDialogButtonBox::Close), SIGNAL(clicked()), this, SIGNAL(closeApp())); #endif //! [1] connect(ui->connectButton, SIGNAL(clicked()), this, SLOT(createNewObject())); connect(ui->intValue, SIGNAL(valueChanged(int)), this, SLOT(intValueChanged(int))); connect(ui->unsetIntButton, SIGNAL(clicked()), this, SLOT(unsetIntValue())); connect(ui->setStringButton, SIGNAL(clicked()), this, SLOT(setStringValue())); connect(ui->setByteArrayButton, SIGNAL(clicked()), this, SLOT(setByteArrayValue())); //! [1] //! [3] createNewObject(); //! [3] }
void Server::handleNetworkMessages() { RakNet::Packet* pPacket = nullptr; while (true) { CalculateDeltaTime(); for ( pPacket = m_pPeerInterface->Receive(); pPacket; m_pPeerInterface->DeallocatePacket(pPacket), pPacket = m_pPeerInterface->Receive()) { switch (pPacket->data[0]) { case ID_NEW_INCOMING_CONNECTION: { addNewConnection(pPacket->systemAddress); std::cout << "A connection is incoming.\n"; break; } case ID_DISCONNECTION_NOTIFICATION: std::cout << "A client has disconnected.\n"; removeConnection(pPacket->systemAddress); break; case ID_CONNECTION_LOST: std::cout << "A client lost the connection.\n"; removeConnection(pPacket->systemAddress); break; case ID_CLIENT_CREATE_OBJECT: { RakNet::BitStream bsIn(pPacket->data, pPacket->length, false); bsIn.IgnoreBytes(sizeof(RakNet::MessageID)); createNewObject(bsIn, pPacket->systemAddress); break; } case ID_CLIENT_UPDATE_OBJECT_POSITION: { RakNet::BitStream bsIn(pPacket->data, pPacket->length, false); bsIn.IgnoreBytes(sizeof(RakNet::MessageID)); moveGameObject(bsIn, pPacket->systemAddress); break; } case ID_CLIENT_UPDATE_OBJECT_VELOCITY: { pPacket->data[0] = ID_SERVER_VELOCITY_OBJECT_DATA; RakNet::BitStream bsIn(pPacket->data, pPacket->length, false); //bsIn.IgnoreBytes(sizeof(RakNet::MessageID)); m_pPeerInterface->Send(&bsIn, IMMEDIATE_PRIORITY, RELIABLE_ORDERED, 0, RakNet::UNASSIGNED_SYSTEM_ADDRESS, true); break; } default: std::cout << "Received a message with a unknown ID: " << pPacket->data[0]; break; } } } }
void TrackMapInput_c::undo( ) { if( undoEventStack.size() > 0 ) { undoEventStack.top()->undo(); redoEventStack.push( createNewObject( undoEventStack.top() ) ); undoEventStack.pop(); } else { std::cout << "Undo stack is Empty " << std::endl; } }
PublisherDialog::PublisherDialog(QWidget *parent) : QDialog(parent), ui(new Ui::PublisherDialog), publisher(0) { ui->setupUi(this); #ifdef QTM_EXAMPLES_SMALL_SCREEN QPushButton *switchButton = ui->buttonBox->addButton(tr("Switch"), QDialogButtonBox::ActionRole); connect(switchButton, SIGNAL(clicked()), this, SIGNAL(switchRequested())); #endif //! [1] connect(ui->connectButton, SIGNAL(clicked()), this, SLOT(createNewObject())); connect(ui->intValue, SIGNAL(valueChanged(int)), this, SLOT(intValueChanged(int))); connect(ui->unsetIntButton, SIGNAL(clicked()), this, SLOT(unsetIntValue())); connect(ui->setStringButton, SIGNAL(clicked()), this, SLOT(setStringValue())); connect(ui->setByteArrayButton, SIGNAL(clicked()), this, SLOT(setByteArrayValue())); //! [1] //! [3] createNewObject(); //! [3] }
void ObjectTracker::matchObjects(CvPoint *newCenters, int size) { if (currObjs_.empty()) { for (int i=0; i<size; i++) { createNewObject(newCenters[i]); } return; } if (size == 0) { removeObjects(); } int parameter = imgSize_.width + imgSize_.height; int rows = currObjs_.size(); int cols = size; objsM_ = new double*[rows]; for (int i=0; i<rows; i++) { objsM_[i] = new double[cols]; } CvPoint *predictedPnts = new CvPoint[rows]; for (int i=0; i<rows; i++) { predictedPnts[i] = currObjs_[i].predictNextPosition(); } for (int i=0; i<rows; i++) { for (int j=0; j<cols; j++) { CvPoint distance = subVectors(predictedPnts[i], newCenters[j]); objsM_[i][j] = getMagnitude(distance) / parameter; } } vector<int> list; // Check columns for (int j=0; j<cols; j++) { list.clear(); for (int i=0; i<rows; i++) { if (objsM_[i][j] < matchThreshold_) { list.push_back(i); } } switch (list.size()) { case 0: // New object createNewObject(newCenters[j]); break; case 1: break; default: break; } } // Check rows vector<int> removedObjectsv; removedObjectsv.clear(); for (int i=0; i<rows; i++) { list.clear(); for (int j=0; j<cols; j++) { if (objsM_[i][j] < matchThreshold_) { list.push_back(j); } } switch(list.size()) { case 0: // No more match removedObjectsv.push_back(i); break; case 1: currObjs_[i].correctPosition(newCenters[list[0]]); break; default: break; } } removeObjects(&removedObjectsv); //printMatrix(objsM_, rows, cols); for (int i=0; i<rows; i++) { delete[] objsM_[i]; } delete[] objsM_; }