void Camera::moveForward(double dist) { // move the camera forward (in the viewing direction) // by the amount dist Vector3 temp = eye + -n*dist; Point3 pts = Point3(temp[0],temp[1], temp[2]); setFrom(pts); }
void Camera::moveVertical(double dist) { // move the camera vertically (along the up vector) // by the amount dist Vector3 temp = eye + Up_Vector*dist; Point3 pts = Point3(temp[0], temp[1], temp[2]); setFrom(pts); }
foreach (const QString &headerRow, headerLines) { QRegExp messageIdRx("^Message-ID: (.*)$", Qt::CaseInsensitive); QRegExp fromRx("^From: (.*)$", Qt::CaseInsensitive); QRegExp toRx("^To: (.*)$", Qt::CaseInsensitive); QRegExp ccRx("^Cc: (.*)$", Qt::CaseInsensitive); QRegExp subjectRx("^Subject: (.*)$", Qt::CaseInsensitive); QRegExp dateRx("^Date: (.*)$", Qt::CaseInsensitive); QRegExp mimeVerstionRx("^MIME-Version: (.*)$", Qt::CaseInsensitive); QRegExp contentTransferEncodingRx("^Content-Transfer-Encoding: (.*)$", Qt::CaseInsensitive); QRegExp contentTypeRx("^Content-Type: (.*)$", Qt::CaseInsensitive); if (messageIdRx.indexIn(headerRow) != -1) setMessageId(messageIdRx.cap(1)); else if (fromRx.indexIn(headerRow) != -1) setFrom(headerDecode(fromRx.cap(1))); else if (toRx.indexIn(headerRow) != -1) setTo(headerDecode(toRx.cap(1))); else if (ccRx.indexIn(headerRow) != -1) setCc(headerDecode(ccRx.cap(1))); else if (subjectRx.indexIn(headerRow) != -1) setSubject(headerDecode(subjectRx.cap(1))); else if (dateRx.indexIn(headerRow) != -1) { QDateTime date = QDateTime::fromString(dateRx.cap(1), Qt::RFC2822Date); setDate(date); } else if (mimeVerstionRx.indexIn(headerRow) != -1) setMimeVersion(mimeVerstionRx.cap(1)); else if (contentTransferEncodingRx.indexIn(headerRow) != -1) setContentTransferEncoding(IqPostmanAbstractContent::contentTransferEncodingFromString(headerRow)); else if (contentTypeRx.indexIn(headerRow) != -1) setContentType(IqPostmanAbstractContentType::createFromString(headerRow)); }
bool JabberChatService::sendMessage(const Message &message) { if (!m_client) return false; auto jid = m_resourceService->bestChatJid(message.messageChat()); if (jid.isEmpty()) return false; auto xmppMessage = QXmppMessage{}; FormattedStringPlainTextVisitor plainTextVisitor; message.content()->accept(&plainTextVisitor); auto plain = plainTextVisitor.result(); if (rawMessageTransformerService()) plain = QString::fromUtf8(rawMessageTransformerService()->transform(plain.toUtf8(), {message}).rawContent()); xmppMessage.setBody(plain); xmppMessage.setFrom(m_client.data()->clientPresence().id()); xmppMessage.setStamp(QDateTime::currentDateTime()); xmppMessage.setTo(jid.full()); xmppMessage.setType(chatMessageType(message.messageChat(), jid.bare())); m_client.data()->sendPacket(m_chatStateService->withSentChatState(xmppMessage)); return true; }
void Camera::moveSideways(double dist) { // move the camera sideways (orthogonal to the viewing direction) // by the amount dist Vector3 temp_r = getRight(); Vector3 temp = eye + temp_r*dist; Point3 pts = Point3(temp[0], temp[1], temp[2]); setFrom(pts); }
void JabberChatStateService::sendState(const Contact &contact, ChatState state) { if (!m_client || !m_client->isConnected()) return; if (!contact || contact.currentStatus().isDisconnected()) return; auto receivedChatState = static_cast<QXmppMessage::State>(contact.property("jabber:received-chat-state", QXmppMessage::State::None).toInt()); if (receivedChatState == QXmppMessage::State::None || receivedChatState == QXmppMessage::State::Gone) return; auto jabberAccountDetails = dynamic_cast<JabberAccountDetails *>(account().details()); if (!jabberAccountDetails || !jabberAccountDetails->sendTypingNotification()) return; auto xmppState = stateToXmppState(state); if (!jabberAccountDetails->sendGoneNotification() && (xmppState == QXmppMessage::State::Gone || xmppState == QXmppMessage::State::Inactive)) xmppState = QXmppMessage::State::Paused; auto sentChatState = static_cast<QXmppMessage::State>(contact.property("jabber:sent-chat-state", QXmppMessage::State::None).toInt()); // invalid transition if (sentChatState == QXmppMessage::State::None && (xmppState != QXmppMessage::State::Active && xmppState != QXmppMessage::State::Composing && xmppState != QXmppMessage::State::Gone)) return; // don't send if it is the same as last sent state if (xmppState == sentChatState || xmppState == QXmppMessage::State::None) return; auto jid = m_resourceService->bestContactJid(contact); auto xmppMessage = QXmppMessage{}; xmppMessage.setFrom(m_client.data()->clientPresence().id()); xmppMessage.setStamp(QDateTime::currentDateTime()); xmppMessage.setTo(jid.full()); xmppMessage.setType(QXmppMessage::Chat); if (xmppState == QXmppMessage::State::Inactive && sentChatState == QXmppMessage::State::Composing) { // send intermediate state first xmppMessage.setState(QXmppMessage::State::Paused); m_client->sendPacket(xmppMessage); } if (xmppState == QXmppMessage::State::Composing && sentChatState == QXmppMessage::State::Inactive) { // send intermediate state first xmppMessage.setState(QXmppMessage::State::Active); m_client->sendPacket(xmppMessage); } xmppMessage.setState(xmppState); m_client->sendPacket(xmppMessage); // Save last state // if (sentChatState != QXmppMessage::State::Gone || xmppState == QXmppMessage::State::Active) I don't know why we have this condition contact.addProperty("jabber:sent-chat-state", static_cast<int>(xmppState), CustomProperties::NonStorable); }
TimeZoneTransition& TimeZoneTransition::operator=(const TimeZoneTransition& right) { if (this != &right) { fTime = right.fTime; setFrom(*right.fFrom); setTo(*right.fTo); } return *this; }
/*** Constructor ***/ For::For() { setFrom(0); setTo(0); setStep(0); setFor(0); setWhileCondition(0); setUntilCondition(0); setStatements(0); }
MailSender::MailSender(const QString& smtpServer, const QString& sender, const QString& receipient) { setSmtpServer(smtpServer); setPort(25); setTimeout(30000); setFrom(sender); QStringList recipients; recipients << receipient; setTo(recipients); }
Message2::Message2(const ConnectionInfo &AInfo) { FStanza = new Stanza(); QDomElement el = stanza().addElement(TNOXMPP_DATA, TNOXMPP_XMLNS); QDomText dataSec = stanza().document().createTextNode(""); el.appendChild(dataSec); setFrom(AInfo.jid); setTo(AInfo.remoteJid); setFromSid(AInfo.sid); setToSid(AInfo.remoteSid); }
void RootOperationData::setAttr(const std::string& name, const Element& attr) { if (name == SERIALNO_ATTR) { setSerialno(attr.asInt()); return; } if (name == REFNO_ATTR) { setRefno(attr.asInt()); return; } if (name == FROM_ATTR) { setFrom(attr.asString()); return; } if (name == TO_ATTR) { setTo(attr.asString()); return; } if (name == SECONDS_ATTR) { setSeconds(attr.asFloat()); return; } if (name == FUTURE_SECONDS_ATTR) { setFutureSeconds(attr.asFloat()); return; } if (name == ARGS_ATTR) { setArgsAsList(attr.asList()); return; } RootData::setAttr(name, attr); }
Camera::Camera() { // initialize your data here aspect_ratio = 1.0; height = 600; width = 800; setFrom(Point3(3.0, 2.0, 6.0)); setAt(Point3(0.0, 0.0, 0.0)); setUp(Vector3(0.0, 1.0, 0.0)); setZoom(90.0); setNearFar(0.1, 30.0); }
void Period::changePart(int s) { if(!type) { addSecs(s*secs()); return; } uint np = type->parts.size(); if(np) { uint p = (part + np + s)%np; if(part == 0 && s < 0) add(t1, type->base, -1); if(part == np - 1 && s > 0) add(t1, type->base, 1); part = p; QDateTime dt = set(from(), type->base, type->parts[part]); setFrom(dt); setTo(dt); p = (part + 1)%np; if(part == np - 1) add(t2, type->base, 1); setTo(set(to(), type->base, type->parts[p])); } else { setFrom(set(from(), type->base)); add(t1, type->base, s); t2 = t1; add(t2, type->base, 1); } }
Period & Period::at(const QDateTime &dt, const PeriodType *t) { type = t; if(type) { setFrom(dt); Duration dur = dt % type->base; uint np = type->parts.size(); if(np) { for(part = 0; part < np - 1; part++) if(type->parts[part + 1] > dur) break; if(type->parts[part] > dur) { changePart(-1); return *this; } } } changePart(0); return *this; }
void PerspectiveCamera::load(const QString &filename) { FILE *fp=fopen(filename.toStdString().c_str(),"rb"); float sfov=0; float sfarPlane=0; float snearPlane=0; GGL::Point3f sfrom; GGL::Point3f sto; GGL::Point3f sup; fread(&sfov,sizeof(float),1,fp); qDebug("fov:%f",sfov); fread(&sfarPlane,sizeof(float),1,fp); qDebug("far plane:%f",sfarPlane); fread(&snearPlane,sizeof(float),1,fp); qDebug("near plane:%f",snearPlane); float vsfrom[3]; fread(vsfrom,sizeof(float),3,fp); qDebug("from:%f,%f,%f",vsfrom[0],vsfrom[1],vsfrom[2]); float vsto[3]; fread(vsto,sizeof(float),3,fp); qDebug("to:%f,%f,%f",vsto[0],vsto[1],vsto[2]); float vsup[3]; fread(vsup,sizeof(float),3,fp); qDebug("up:%f,%f,%f",vsup[0],vsup[1],vsup[2]); fclose(fp); setFov(sfov); setFarPlane(sfarPlane); setNearPlane(snearPlane); setFrom(GGL::Point3f(vsfrom[0],vsfrom[1],vsfrom[2])); setTo(GGL::Point3f(vsto[0],vsto[1],vsto[2])); setUp(GGL::Point3f(vsup[0],vsup[1],vsup[2])); }
bool JabberChatService::sendRawMessage(const Chat &chat, const QByteArray &rawMessage) { if (!m_client) return false; auto jid = m_resourceService->bestChatJid(chat); if (jid.isEmpty()) return false; auto xmppMessage = QXmppMessage{}; xmppMessage.setBody(rawMessage); xmppMessage.setFrom(m_client.data()->clientPresence().id()); xmppMessage.setStamp(QDateTime::currentDateTime()); xmppMessage.setTo(jid.full()); xmppMessage.setType(chatMessageType(chat, jid.bare())); m_client.data()->sendPacket(m_chatStateService->withSentChatState(xmppMessage)); return true; }
void Camera::rotateAroundAtPoint(int axis, double angle, double focusDist) { Matrix4 matRot; if ( axis == 0 ) matRot = Matrix4::xrotation(angle); if ( axis == 1 ) matRot = Matrix4::yrotation(angle); if ( axis == 2 ) matRot = Matrix4::zrotation(angle); const Point3 ptFocus = getEye() + getLook() * focusDist; const Matrix4 matRotCameraInv = getRotationFromXYZ(); const Matrix4 matAll = matRotCameraInv * matRot * matRotCameraInv.transpose(); const double dScl = focusDist * tan( getZoom() / 2.0 ); const double dXOff = 1.0 / arScale * ptCOP[0] * dScl - skew * ptCOP[1]; const double dYOff = ptCOP[1] * dScl; // Undo center of projection pan to find true at point const Vector3 vecUndoCOPPan = dXOff * getRight() + dYOff * getUp(); // Should keep unit and ortho, but reset just to make sure const Vector3 vecFrom = matAll * (getEye() - ptFocus); const Vector3 vecUp = unit( matAll * getUp() ); const Vector3 vecRight = unit( matAll * getRight() ); // Undo center of projection pan to find true at point const Vector3 vecRedoCOPPan = dXOff * vecRight + dYOff * vecUp; // Find from point if we rotated around the correct at point, then fixed the pan const Point3 ptFrom = (ptFocus + vecUndoCOPPan) + vecFrom - vecRedoCOPPan; // Correct the at point for the COP pan, then add in the new COP pan const Point3 ptAt = (ptFocus + vecUndoCOPPan) - vecRedoCOPPan; setFrom( ptFrom ); setAt( ptAt ); setUp( vecUp ); }
void ParticleParameter::parseFromTokens(parser::DefTokeniser& tok) { std::string val = tok.nextToken(); try { setFrom(boost::lexical_cast<float>(val)); } catch (boost::bad_lexical_cast&) { rError() << "[particles] Bad lower value, token is '" << val << "'" << std::endl; } if (tok.peek() == "to") { // Upper value is there, parse it tok.skipTokens(1); // skip the "to" val = tok.nextToken(); try { // cut off the quotes before converting to double setTo(boost::lexical_cast<float>(val)); } catch (boost::bad_lexical_cast&) { rError() << "[particles] Bad upper value, token is '" << val << "'" << std::endl; } } else { setTo(getFrom()); } }
void DateSelector::resetFrom() { setFrom(QDate(1, 1, 1)); }
void Move::setFrom(int first, int second) { setFrom(Pos(first, second )); }
void CPUBuffer::setFrom(const PinnedCPUBuffer& src, size_t srcBegin, size_t srcEnd, size_t destBegin) { setFrom((const CPUBuffer&)src, srcBegin, srcEnd, destBegin); }
JingleStanza::JingleStanza(const Jid &AFrom, const Jid &ATo, const QString &ASid, IJingle::Action AAction): Stanza("iq"), jingle(addElement("jingle", NS_JINGLE)) { QString action; switch (AAction) { case IJingle::SessionInitiate: action="session-initiate"; break; case IJingle::SessionAccept: action="session-accept"; break; case IJingle::SessionTerminate: action="session-terminate"; break; case IJingle::SessionInfo: action="session-info"; break; case IJingle::ScurityInfo: action="security-info"; break; case IJingle::DescriptionInfo: action="description-info"; break; case IJingle::ContentAdd: action="content-add"; break; case IJingle::ContentModify: action="content-modify"; break; case IJingle::ContentAccept: action="content-accept"; break; case IJingle::ContentReject: action="content-reject"; break; case IJingle::ContentRemove: action="content-remove"; break; case IJingle::TransportAccept: action="transport-accept"; break; case IJingle::TransportInfo: action="transport-info"; break; case IJingle::TransportReject: action="transport-reject"; break; case IJingle::TransportReplace: action="transport-replace"; break; default: return; } setType("set"); setFrom(AFrom.full()); setTo(ATo.full()); setId(QString("id%1").arg(QDateTime::currentDateTime().toTime_t(),0,16)); jingle.setAttribute("action", action); jingle.setAttribute("sid", ASid); }