void ArrowLine::drawShape(QPainter &p) { p.setPen(darkGray); QCanvasLine::drawShape(p); double angle = computeAngle(startPoint().x(), startPoint().y(), endPoint().x(), endPoint().y()); QPointArray pts(3); QWMatrix m; int x, y; m.rotate(angle); m.map(-5, -2, &x, &y); pts.setPoint(0, x, y); m.map(-5, 2, &x, &y); pts.setPoint(1, x, y); m.map(0, 0, &x, &y); pts.setPoint(2, x, y); pts.translate(endPoint().x(), endPoint().y()); p.setBrush(QColor(darkGray)); p.drawPolygon(pts); }
void AMBeamSelectPage::initializePage() { AMViewPage::initializePage(); disconnect(view(), SIGNAL(mousePressed(QPointF)), viewWizard(), SLOT(addPoint(QPointF))); disconnect(view(), SIGNAL(mouseLeftReleased(QPointF)), viewWizard(), SLOT(endPoint())); connect(view(), SIGNAL(mousePressed(QPointF)), viewWizard(), SLOT(addPoint(QPointF))); connect(view(), SIGNAL(mouseLeftReleased(QPointF)), viewWizard(), SLOT(endPoint())); }
////////////////// PathInfo ////////////////// PathInfo::PathInfo(const Unit* owner, const float destX, const float destY, const float destZ, bool useStraightPath) : m_pathPolyRefs(NULL), m_polyLength(0), m_type(PATHFIND_BLANK), m_useStraightPath(useStraightPath), m_sourceUnit(owner), m_navMesh(NULL), m_navMeshQuery(NULL) { PathNode endPoint(destX, destY, destZ); setEndPosition(endPoint); float x,y,z; m_sourceUnit->GetPosition(x, y, z); PathNode startPoint(x, y, m_sourceUnit->GetMap()->GetHeight(x,y,z,100.0f)); setStartPosition(startPoint); PATH_DEBUG("++ PathInfo::PathInfo for %u \n", m_sourceUnit->GetGUID()); uint32 mapId = m_sourceUnit->GetMapId(); MMAP::MMapManager* mmap = MMAP::MMapFactory::createOrGetMMapManager(); m_navMesh = mmap->GetNavMesh(mapId); m_navMeshQuery = mmap->GetNavMeshQuery(mapId); if (m_navMesh && m_navMeshQuery) { BuildPolyPath(startPoint, endPoint); } else { BuildShortcut(); m_type = PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH); } }
void PD_2DXYPS::DrawXAxes(const double& yVal, const double& yaxOffset) { Point2D stPoint(convXaxisMin, yVal + yaxOffset); Point2D endPoint(convXaxisMax, yVal + yaxOffset); DrawLine(stPoint, endPoint); }
////////////////// PathInfo ////////////////// PathInfo::PathInfo(const Unit* owner, const float destX, const float destY, const float destZ, bool useStraightPath) : m_polyLength(0), m_type(PATHFIND_BLANK), m_useStraightPath(useStraightPath), m_sourceUnit(owner), m_navMesh(NULL), m_navMeshQuery(NULL) { PathNode endPoint(destX, destY, destZ); setEndPosition(endPoint); float x,y,z; m_sourceUnit->GetPosition(x, y, z); PathNode startPoint(x, y, z); setStartPosition(startPoint); DEBUG_FILTER_LOG(LOG_FILTER_PATHFINDING, "++ PathInfo::PathInfo for %u \n", m_sourceUnit->GetGUID()); uint32 mapId = m_sourceUnit->GetMapId(); if (MMAP::MMapFactory::IsPathfindingEnabled(mapId)) { MMAP::MMapManager* mmap = MMAP::MMapFactory::createOrGetMMapManager(); m_navMesh = mmap->GetNavMesh(mapId); m_navMeshQuery = mmap->GetNavMeshQuery(mapId, m_sourceUnit->GetInstanceId()); } createFilter(); if (m_navMesh && m_navMeshQuery && !m_sourceUnit->hasUnitState(UNIT_STAT_IGNORE_PATHFINDING)) { BuildPolyPath(startPoint, endPoint); } else { BuildShortcut(); m_type = PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH); } }
void KviCanvasLine::draw(QPainter &p) { if(isEnabled()) { p.setPen(pen()); p.drawLine(startPoint(),endPoint()); } if(isSelected()) { p.setRasterOp(NotROP); p.setPen(QPen(DotLine)); p.drawLine(startPoint(),endPoint()); p.setRasterOp(CopyROP); } }
void LayoutSVGResourceLinearGradient::buildGradient(GradientData* gradientData) const { const LinearGradientAttributes& attributes = this->attributes(); gradientData->gradient = Gradient::create(startPoint(attributes), endPoint(attributes)); gradientData->gradient->setSpreadMethod(platformSpreadMethodFromSVGType(attributes.spreadMethod())); addStops(gradientData, attributes.stops()); }
void Tranceiver::connect(String ipAddr) { semaphore.Acquire(); //create socket socket=new Socket(); socket->Construct(NET_SOCKET_AF_IPV4, NET_SOCKET_TYPE_STREAM, NET_SOCKET_PROTOCOL_TCP); unsigned long blockingModeSocket=0; socket->Ioctl(NET_SOCKET_FIONBIO, blockingModeSocket); //Connect to TCP Server Ip4Address ipAddress(ipAddr); NetEndPoint endPoint(ipAddress, PORT); result r=socket->Connect(endPoint); if(r!=E_SUCCESS) { AppLogException("CommandCenter : Connect Error"); } //Create Packet Object packetSender=new PacketSender(socket); screenSender=new ScreenSender(socket); packetReceiver=new PacketReceiver(socket); //Start PacketReciever packetReceiver->setPacketListener(this); packetReceiver->Construct(); packetReceiver->flag=true; packetReceiver->Start(); //mServerConnectionListener->onServerConnected(ipAddr); semaphore.Release(); }
void PD_2DXYPS::DrawYAxes(const double& xVal, const double& xaxOffset) { Point2D stPoint(xVal + xaxOffset, convYaxisMin); Point2D endPoint(xVal + xaxOffset, convYaxisMax); DrawLine(stPoint, endPoint); }
double LikelihoodField::computeWeight(const std::vector<double>& measurement, const std::vector<double>& state, const Grid<double>& map){ double q = 1; //Get location of range finder in global coordinates std::vector<double> locationRF = this->rf->getLocation(state); std::vector<double> endPoint(2); //Temporary variables double z,minDist,dist,sample, beamAngle; for(int i = 0; i < (int)measurement.size(); i++){ //Current measurement z = measurement[i]; beamAngle = this->rf->getBeamAngle(i); if (z != this->rf->getErrorValue()){ //Compute end position of current beam endPoint[0] = locationRF[0] + z * cos(beamAngle + state[2]); endPoint[1] = locationRF[1] + z * sin(beamAngle + state[2]); //Find nearest occupied cell in map minDist = 0; for(int j = 0; j < map.getNumberCells(); j++){ Cell<double> c = map.getCell(j); if(c.value > this->parameters[4]){ dist = c.getDistanceToCenter(endPoint); if(dist < minDist || minDist == 0) minDist = dist; } } //Update probability of measurement sample = Tools::probNormal(minDist, this->parameters[0]); q = q * (this->parameters[1] * sample + this->parameters[2]/this->parameters[3]); } } return q; }
RTRVector3D RTRSegment::pointAt(int coordinate, double val) const { //TODO Not finished... I want to sleep!! double ratio = (val - beginningPoint(coordinate)) / (endPoint(coordinate) - beginningPoint(coordinate)); RTRVector3D ret = beginningPoint + (endPoint - beginningPoint) * ratio; ret(coordinate) = val; return ret; }
void VNode::render() const { glColor3f(0,1,0); glLineWidth(MaxWidth); DrawLine( m_location, endPoint() ); int numChildren = (int)m_children.size(); for(int i=0; i<numChildren; ++i) m_children[i]->render(); }
bool QgsCurve::isClosed() const { if ( numPoints() == 0 ) return false; //don't consider M-coordinates when testing closedness QgsPointV2 start = startPoint(); QgsPointV2 end = endPoint(); return ( qgsDoubleNear( start.x(), end.x(), 1E-8 ) && qgsDoubleNear( start.y(), end.y(), 1E-8 ) && qgsDoubleNear( start.z(), end.z(), 1E-8 ) ); }
int server() { printf("Give me the printer Number : 0 or 1"); int no; scanf("%d",&no); char buffer[256] = { '\0' }; // Create a local endpoint. if(no==0) sprintf(buffer, "tcp://58.198.176.121:5555"); else sprintf(buffer, "tcp://58.198.176.121:5557"); Theron::EndPoint endPoint("server", buffer); // Connect to the remote endpoint. sprintf(buffer, "tcp://58.198.176.121:5556"); if (!endPoint.Connect(buffer)) { printf("ERROR: Connection failed - check networking is enabled.\n"); return 1; } // The framework and receiver are tied to the endpoint. if(no==0) { //Theron::Receiver receiver(endPoint, "receiver"); Theron::Framework framework(endPoint); Printer printer(no,framework, "printer"); Printer1 printer1(no,framework, "printer1"); //receiver.Wait(); while(1); } else { Theron::Receiver receiver(endPoint, "receiver1"); Theron::Framework framework(endPoint); Printer printer1(no,framework,"printer"); receiver.Wait(); } }
int client() { char buffer[256] = { '\0' }; // Create a local endpoint. sprintf(buffer, "tcp://58.198.176.121:5556"); Theron::EndPoint endPoint("client", buffer); // Connect to the remote endpoint. sprintf(buffer, "tcp://58.198.176.121:5555"); if (!endPoint.Connect(buffer)) { printf("ERROR: Connection failed - check networking is enabled.\n"); return 1; } else { printf("Connected to %s\n",buffer); } sprintf(buffer, "tcp://58.198.176.121:5557"); if (!endPoint.Connect(buffer)) { printf("ERROR: Connection failed - check networking is enabled.\n"); return 1; } else { printf("Connected to %s\n",buffer); } // The framework is tied to the endpoint. Theron::Framework framework(endPoint); // Send messages to the server in a loop until the user enters 'exit'. // Note that if the server hasn't started listening yet it may miss the first messages! printf("Enter lines of text (max 256 chars per line). Type 'exit' to end.\n"); while (strcmp(buffer, "exit") != 0) { // Send the text in a messages to the remote 'printer' actor using its unique name. gets(buffer); framework.Send( TextMessage(buffer), Theron::Address(), Theron::Address("printer")); framework.Send( double(28.234), Theron::Address(), Theron::Address("printer1")); } }
void VNode::grow(const Vector2& targetPoint, bool& reachedTarget, VINENODES& newChildren, VINENODES& staleChildren) { incrementGrowth(); setEndPoint(); float distance = sqrt( pow((targetPoint.X - endPoint().X),2) + pow((targetPoint.Y - endPoint().Y),2) ); reachedTarget = bool(distance <= GrowthIncrement); if(!reachedTarget) { if(maxLengthReached()) { staleChildren.push_back(this); addRandomizedChildren(endPoint(), targetPoint); int sz = (int)m_children.size(); for( int i=0; i<sz; ++i ) newChildren.push_back(m_children[i]); } } }
QgsAbstractGeometry *QgsCurve::boundary() const { if ( isEmpty() ) return nullptr; if ( isClosed() ) return nullptr; QgsMultiPoint *multiPoint = new QgsMultiPoint(); multiPoint->addGeometry( new QgsPoint( startPoint() ) ); multiPoint->addGeometry( new QgsPoint( endPoint() ) ); return multiPoint; }
/** * Return whether on seq. line. * Takes into account destruction box if shown. * * @param p The point to investigate. * @return Non-zero if point is on this sequence line. */ int SeqLineWidget::onWidget(const QPoint & p) { int nOnWidget = 0; QPoint sp = startPoint(); QPoint ep = endPoint(); //see if on widget ( for message creation ) if( sp.x() - m_nMouseDownEpsilonX < p.x() && ep.x() + m_nMouseDownEpsilonX > p.x() && sp.y() < p.y() && ep.y() + 3 > p.y() ) { nOnWidget = 1; } return nOnWidget; }
void ReportPrintSetting::drawPosition(int type, QString content, QPainter &painter, int drawType,QString img, int fontSize, const QString family, bool bold) { ReportFormDefinition report; // QString file("../tcdstation/reportForm.xml"); QString file("reportForm.xml"); report.ReadReportContent(file); QRectF rectF; report.GetPosition(type,rectF); QFont font; font.setPointSize(fontSize); font.setBold(bold); font.setFamily(family); painter.setFont(font); if(drawType == SPLITTER) { QPoint startPoint(rectF.x(),rectF.y()); QPoint endPoint(rectF.x()+rectF.width(),rectF.y()+rectF.height()); painter.drawLine(startPoint,endPoint); } else if(drawType == TEXT) { painter.drawText(rectF,Qt::TextWordWrap,content); } else if(drawType == IMAGE) { //QImage image(img); QPixmap pixmap; pixmap.load(img); //painter.drawImage(rectF,image); painter.drawPixmap(rectF.x(),rectF.y(),rectF.width(),rectF.height(),pixmap); } else if(drawType == WIDGET) { QPixmap grabImage; QRect rect; rect.setSize(QSize(rectF.width(),rectF.height())); m_tableView->resize(rect.size()); grabImage = m_tableView->grab(QRect(0,0,m_tableView->width(),m_tableView->height())); grabImage.scaled(rect.size(),Qt::KeepAspectRatio); painter.drawPixmap(rectF.x(),rectF.y(),grabImage); } }
void PD_2DXYPS::DrawXTic(const double& xVal, const double& yVal, const double& yaxOffset, const double& ticLen, const double& ticOffset) { double xTran = TransformX(xVal); if (Limit::WithinOneLimit(convXaxisMin, convXaxisMax, xTran)) { double ypt = yVal + yaxOffset - ticOffset; Point2D stPoint(xTran, ypt); Point2D endPoint(xTran, ypt + ticLen); DrawLine(stPoint, endPoint); } }
/** * Arrow class contructor, that creates and arrow from a start item * to the endItem * @param startItem * @param endItem * @param parentGroup */ Arrow::Arrow(DocBlock *startItem, Block *endItem, BlockGroup *parentGroup) : QGraphicsLineItem(parentGroup) { Q_ASSERT(startItem != 0);Q_ASSERT(endItem != 0);Q_ASSERT(parentGroup != 0); myStartItem = startItem; myEndItem = endItem; myColor = Qt::black; setPen(QPen(myColor, 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); connect(myStartItem, SIGNAL(destroyed()), this, SLOT(deleteLater())); connect(myEndItem, SIGNAL(destroyed()), this, SLOT(deleteLater())); connect(myEndItem, SIGNAL(visibilityChanged(bool)), this, SLOT(updateVisibility(bool))); line1 = QLineF(startPoint(), midPoint()); line2 = QLineF(midPoint(), endPoint()); }
bool QgsCurve::isClosed() const { if ( numPoints() == 0 ) return false; //don't consider M-coordinates when testing closedness QgsPoint start = startPoint(); QgsPoint end = endPoint(); bool closed = qgsDoubleNear( start.x(), end.x(), 1E-8 ) && qgsDoubleNear( start.y(), end.y(), 1E-8 ); if ( is3D() && closed ) closed &= qgsDoubleNear( start.z(), end.z(), 1E-8 ) || ( std::isnan( start.z() ) && std::isnan( end.z() ) ); return closed; }
/** * Loads AssociationLine information saved in \a qElement XMI element. */ bool AssociationLine::loadFromXMI(QDomElement &qElement) { QString layout = qElement.attribute(QLatin1String("layout"), QLatin1String("polyline")); m_layout = fromString(layout); QDomNode node = qElement.firstChild(); m_points.clear(); QDomElement startElement = node.toElement(); if(startElement.isNull() || startElement.tagName() != QLatin1String("startpoint")) { return false; } QString x = startElement.attribute(QLatin1String("startx"), QLatin1String("0")); qreal nX = x.toFloat(); QString y = startElement.attribute(QLatin1String("starty"), QLatin1String("0")); qreal nY = y.toFloat(); QPointF startPoint(nX, nY); node = startElement.nextSibling(); QDomElement endElement = node.toElement(); if(endElement.isNull() || endElement.tagName() != QLatin1String("endpoint")) { return false; } x = endElement.attribute(QLatin1String("endx"), QLatin1String("0")); nX = x.toFloat(); y = endElement.attribute(QLatin1String("endy"), QLatin1String("0")); nY = y.toFloat(); QPointF endPoint(nX, nY); setEndPoints(startPoint, endPoint); QPointF point; node = endElement.nextSibling(); QDomElement element = node.toElement(); int i = 1; while(!element.isNull()) { if(element.tagName() == QLatin1String("point")) { x = element.attribute(QLatin1String("x"), QLatin1String("0")); y = element.attribute(QLatin1String("y"), QLatin1String("0")); point.setX(x.toFloat()); point.setY(y.toFloat()); insertPoint(i++, point); } node = element.nextSibling(); element = node.toElement(); } return true; }
void PD_2DXYPS::DrawYTic(const double& xVal, const double& yVal, const double& xaxOffset, const double& ticLen, const double& ticOffset) { double yTran = TransformY(yVal); if (Limit::WithinOneLimit(convYaxisMin, convYaxisMax, yTran)) { double xpt = xVal + xaxOffset - ticOffset; Point2D stPoint(xpt, yTran); Point2D endPoint(xpt + ticLen, yTran); DrawLine(stPoint, endPoint); } }
/* -------------------------------------------------------- OPEN & CLOSE SERVER -------------------------------------------------------- */ template<> void WServer::openServer() { boost::asio::io_service ioService; boost::asio::ip::tcp::endpoint endPoint(boost::asio::ip::tcp::v4(), PORT()); boost::asio::ip::tcp::acceptor acceptor(ioService, endPoint); this->ip = WCharset::_t( endPoint.address().to_v4().to_string() ); while (true) { boost::asio::ip::tcp::socket *socket = new boost::asio::ip::tcp::socket(ioService); acceptor.accept(*socket); thread(&WServer::addClient, this, socket).detach(); } }
void Link::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) { if (myStartItem->collidesWithItem(myEndItem)) return; QPen myPen = pen(); myPen.setColor(myColor); painter->setPen(myPen); painter->setBrush(myColor); QPointF startPoint(myStartItem->pos().x() + myStartItem->pixmap().height()/2, myStartItem->pos().y() + myStartItem->pixmap().width()/2); QPointF endPoint(myEndItem->pos().x() + myEndItem->pixmap().height()/2, myEndItem->pos().y() + myEndItem->pixmap().width()/2); setLine(QLineF(startPoint, endPoint)); painter->drawLine(line()); }
void LineMove::prepare(PageItem_Line* line, bool useOriginAsEndpoint) { m_haveLineItem = (line != NULL); if (!m_haveLineItem) return; m_useOriginAsEndpoint = useOriginAsEndpoint; m_line = line; setStartPoint(QPointF(m_line->xPos(), m_line->yPos())); setEndPoint(QPointF(m_line->xPos() + m_line->width(), m_line->yPos())); setRotation(m_line->rotation()); if (m_useOriginAsEndpoint) { QPointF tmp = startPoint(); setStartPoint(endPoint()); setEndPoint(tmp); } }
void CurveBrush::strokePens(QPointF pi1, QPointF pi2, KisPainter &/*painter*/) { if (m_pens.isEmpty()) { m_pens.append(Pen(pi1, 0.0, 1.0)); } qreal dx = pi2.x() - pi1.x(); qreal dy = pi2.y() - pi1.y(); for (int i = 0; i < m_pens.length(); i++) { Pen &pen = m_pens[i]; QPointF endPoint(dx, dy); QPainterPath path; path.moveTo(0, 0); path.lineTo(dx, dy); QTransform transform; transform.reset(); transform.translate(pen.pos.x(), pen.pos.y()); transform.scale(pen.scale, pen.scale); transform.rotate(pen.rotation); path = transform.map(path); //m_painter->drawPainterPath(path, QPen(Qt::white, 1.0)); endPoint = transform.map(endPoint); m_painter->drawThickLine(pen.pos, endPoint, 1.0, 1.0); pen.pos = endPoint; } qreal branchThreshold = 0.5; if ((m_branch * drand48() > branchThreshold) && (m_pens.length() < 1024)) { int index = floor(drand48() * (m_pens.length() - 1)); m_newPen.pos = m_pens.at(index).pos; m_newPen.rotation = drand48() * M_PI / 32; //atan(dy/dx) + (drand48() - 0.5) * M_PI/32; m_newPen.scale = drand48() * m_pens.at(index).scale; m_pens.append(m_newPen); dbgKrita << m_pens.length(); m_branch = 0; } else { m_branch++; } }
void PD_2DXYPS::DrawXGrid(const double& xVal, const double& yminOffset, const double& ymaxOffset, const double& ticOffset) { double xTran = TransformX(xVal); if (plotAnnotation.DoYAxis() && (xTran == convXaxisMin)) return; if (plotAnnotation.DoYAxis() && plotAnnotation.framePlot && (xTran == convXaxisMax)) return; if (Limit::WithinOneLimit(convXaxisMin, convXaxisMax, xTran)) { Point2D stPoint(xTran, convYaxisMin + yminOffset - ticOffset); Point2D endPoint(xTran, convYaxisMax + ymaxOffset + ticOffset); DrawLine(stPoint, endPoint); } }
void PD_2DXYPS::DrawYGrid(const double& yVal, const double& xminOffset, const double& xmaxOffset, const double& ticOffset) { double yTran = TransformY(yVal); if (plotAnnotation.DoXAxis() && (yTran == convYaxisMin)) return; if (plotAnnotation.DoXAxis() && plotAnnotation.framePlot && (yTran == convYaxisMax)) return; if (Limit::WithinOneLimit(convYaxisMin, convYaxisMax, yTran)) { Point2D stPoint(convXaxisMin + xminOffset - ticOffset, yTran); Point2D endPoint(convXaxisMax + xmaxOffset + ticOffset, yTran); DrawLine(stPoint, endPoint); } }