示例#1
0
WPointF WCartesianChart::inverseHv(double x, double y, double width) const
{
   if (orientation_ == Vertical)
    return WPointF(x, y);
  else
    return WPointF(y, width - x); 
}
示例#2
0
文件: WPainterPath.C 项目: DTidd/wt
WPointF WPainterPath::positionAtSegment(int index) const
{
  if (index > 0) {
    const Segment& s = segments_[index - 1];
    switch (s.type()) {
    case Segment::MoveTo:
    case Segment::LineTo:
    case Segment::CubicEnd:
    case Segment::QuadEnd:
      return WPointF(s.x(), s.y());
    case Segment::ArcAngleSweep: {
      int i = segments_.size() - 3;
      double cx = segments_[i].x();
      double cy = segments_[i].y();
      double rx = segments_[i+1].x();
      double ry = segments_[i+1].y();
      double theta1 = segments_[i+2].x();
      double deltaTheta = segments_[i+2].y();

      return getArcPosition(cx, cy, rx, ry, theta1 + deltaTheta);
    }
    default:
      assert(false);
    }
  }

  return WPointF(0, 0);
}
示例#3
0
WPointF WCartesianChart::hv(double x, double y,
			    double width) const
{
  if (orientation_ == Vertical)
    return WPointF(x, y);
  else
    return WPointF(width - y, x);
}
示例#4
0
文件: WPainterPath.C 项目: DTidd/wt
WPointF WPainterPath::getSubPathStart() const
{
  /*
   * Find start point of last sub path, which is the point of the last
   * moveTo operation, or either (0, 0).
   */
  for (int i = segments_.size() - 1; i >= 0; --i)
    if (segments_[i].type() == Segment::MoveTo)
      return WPointF(segments_[i].x(), segments_[i].y());

  return WPointF(0, 0);
}
示例#5
0
WPointF WDataSeries::mapFromDevice(const WPointF& deviceCoordinates) const
{
  if (chart_)
    return chart_->mapFromDevice(deviceCoordinates, yAxis_);
  else
    return WPointF();
}
示例#6
0
void WCartesianChart::IconWidget::paintEvent(Wt::WPaintDevice *paintDevice) 
{
  Wt::WPainter painter(paintDevice);
  chart_->renderLegendIcon(painter, 
			   WPointF(2.5, 10.0), 
			   chart_->series(index_));
}
void PaintBrush::loadImage(const Node& root)
{
    update();
    interactionCount_ = 0;
    actions_.clear();
    vertexList_.clear();
    edgeList_.clear();
    std::list< Node > children = root.children();
    std::list< Node >::iterator it;
    for (it = children.begin(); it != children.end(); ++it)
    {
        if (it->name() == "vertex") vertexList_.push_back(extractVertex(it->children()));
        if (it->name() == "edge") edgeList_.push_back(extractEdge(it->children()));
    }

    // now iterate the edges and update the image.
    std::list< Edge >::iterator eit;
    for (eit = edgeList_.begin(); eit != edgeList_.end(); ++eit)
    {
        Vertex v1 = lookup(eit->v1);
        path_ = WPainterPath(WPointF(v1.x, v1.y));
        path_.addRect(v1.x, v1.y, 1, 1);
        Vertex v2 = lookup(eit->v2);
        path_.lineTo(v2.x, v2.y);
        path_.addRect(v2.x, v2.y, 1, 1);
        actions_.push_back(path_);
    }
    update(PaintUpdate);
}
void PaintBrush::mouseDown(const WMouseEvent& e)
{
    Coordinates c = e.widget();
    if (interactionCount_ % 2 == 0) {
        path_ = WPainterPath(WPointF(c.x, c.y));
        Vertex v;
        v.id = interactionCount_;
        v.x = c.x;
        v.y = c.y;
        vertexList_.push_back(v);
        interactionCount_++;
        path_.addRect(c.x, c.y, 1, 1);
        update(PaintUpdate);
    } else {
        path_.lineTo(c.x, c.y);
        Vertex v;
        v.id = interactionCount_;
        v.x = c.x;
        v.y = c.y;
        vertexList_.push_back(v);
        Edge e;
        e.v1 = v.id - 1;
        e.v2 = v.id;
        e.speed = currentSpeed_;
        edgeList_.push_back(e);
        interactionCount_++;
        path_.addRect(c.x, c.y, 1, 1);
        actions_.push_back(path_);
        update(PaintUpdate);
    }
}
示例#9
0
std::unique_ptr<Shape> ShapesWidget::createRandomShape()
{
  double size = 6 + randomDouble() * 6;

  ShapeColor c = createRandomColor();
		
  double x = size + randomDouble() * (width().value() - 2 * size);
  double y = size + randomDouble() * (height().value() - 2 * size);

  const unsigned amountOfShapes = 2;
  
  unsigned shapeId = randomInt(amountOfShapes);
  if (shapeId == 0)
    return cpp14::make_unique<Circle>(WPointF(x, y), c, size);
  else
    return cpp14::make_unique<Rectangle>(WPointF(x, y), c, size);
}
示例#10
0
WPointF WDataSeries::mapToDevice(const cpp17::any& xValue, const cpp17::any& yValue,
				 int segment) const
{
  if (chart_)
    return chart_->mapToDevice(xValue, yValue, yAxis_, segment);
  else
    return WPointF();
}
示例#11
0
WPointF WCartesianChart::mapFromDevice(const WPointF& point, Axis ordinateAxis)
  const
{
  const WAxis& xAxis = axis(XAxis);
  const WAxis& yAxis = axis(ordinateAxis);

  WPointF p = inverseHv(point.x(), point.y(), width().toPixels());

  return WPointF(xAxis.mapFromDevice(p.x()), yAxis.mapFromDevice(p.y()));
}
示例#12
0
文件: WPainter.C 项目: nkabir/wt
void WPainter::drawRect(double x, double y, double width, double height)
{
    WPainterPath path(WPointF(x, y));

    path.lineTo(x + width, y);
    path.lineTo(x + width, y + height);
    path.lineTo(x, y + height);
    path.closeSubPath();

    drawPath(path);
}
示例#13
0
文件: WPainterPath.C 项目: DTidd/wt
WPointF WPainterPath::beginPosition() const
{
  WPointF result(0, 0);

  for (unsigned int i = 0;
       i < segments_.size() && segments_[i].type() == Segment::MoveTo;
       ++i)
    result = WPointF(segments_[i].x(), segments_[i].y());

  return result;
}
示例#14
0
文件: WPainterPath.C 项目: DTidd/wt
WPointF WPainterPath::getArcPosition(double cx, double cy,
				     double rx, double ry,
				     double angle)
{
  /*
   * angles are counter-clockwise, which means against the logic of
   * the downward X-Y system
   */
  double a = -degreesToRadians(angle);

  return WPointF(cx + rx * std::cos(a), cy + ry * std::sin(a));
}
示例#15
0
文件: WPainter.C 项目: nkabir/wt
void WPainter::drawPie(const WRectF& rectangle, int startAngle, int spanAngle)
{
    WTransform oldTransform = WTransform(worldTransform());

    translate(rectangle.center().x(), rectangle.center().y());
    scale(1., rectangle.height() / rectangle.width());

    WPainterPath path(WPointF(0.0, 0.0));
    path.arcTo(0.0, 0.0, rectangle.width() / 2.0,
               startAngle / 16., spanAngle / 16.);
    path.closeSubPath();

    drawPath(path);

    setWorldTransform(oldTransform);
}
void CGlyphCreator::InitFixpointGlyph()
{
	std::vector<FixpointData> vFixpointData;
	vFixpointData = m_pDataBase->GetFixpointDataVec();
	std::vector<FixpointData>::iterator iter=vFixpointData.begin();
	WGlyphIdentity pIdentity;
	for(; iter != vFixpointData.end(); ++iter)
	{
		WNavPointGlyph *pNavPointGlyph = new WNavPointGlyph;
		WNavPointItemData* npd = pNavPointGlyph->data();

		npd->m_pos = WPointF(iter->GetX(), iter->GetY());
		npd->m_text = iter->GetFixpointName();
		npd->m_navType = 0;

		pIdentity.m_nLayerID = 0;
		pIdentity.strName = iter->GetFixpointName();
			m_pGlyphManager->AddGlyph(GLYPH_NAVPOINT,pIdentity,pNavPointGlyph);
		m_pSimMap->AddItemToMapScene(pNavPointGlyph, GLYPH_NAVPOINT);
	}
}
void WRunwayGlyph::paint(WPainter* painter)
{
	data_type& d = *data();
	WPointF c = d.m_line.center();
	double w = d.m_size.width();
	//double h = d.m_size.height();
	double h = d.m_line.length();
	d.m_dProlongLength = h / 2;

	WPainterProxy proxy(painter);
	painter->setPen(d.m_pen);
	painter->setBrush(WBrush(Ws::NoBrush));
	painter->setWorldTransform(WMatrix().translate(c).rotate(90 - d.m_angle).translate(-c), true);
	painter->drawRect(WRectF(c.x() - h / 2, c.y() - w / 2, h, w));

	if (data()->m_bShowProlong)
	{
		WPointF s(c.x() + h / 2, c.y()); //line start point
		WLineF line(s, WPointF(s.x() + data()->m_dProlongLength, s.y()));
		painter->drawLine(line);

		const size_t scaleCount = data()->m_genericScaleCount * data()->m_detailScaleCount;
		const double genericScaleLength = data()->m_dProlongLength / 20.0;
		const double detailScaleLength = data()->m_dProlongLength / 40.0;
		const double scaleDistance = data()->m_dProlongLength / scaleCount;

		for (size_t i = 1; i < scaleCount + 1; ++i)
		{
			WPointF p(s.x() + i * scaleDistance, s.y());
			WPointF p1(p);
			WPointF p2(p);
			const double& scaleLength = (i % data()->m_detailScaleCount == 0 ? 
			genericScaleLength : detailScaleLength);
			p1.ry() -= scaleLength;
			p2.ry() += scaleLength;
			painter->drawLine(WLineF(p1, p2));
		}
	}
}
示例#18
0
文件: WLineF.C 项目: DTidd/wt
WPointF WLineF::p1() const
{
  return WPointF(x1_, y1_);
}
示例#19
0
文件: WPainterPath.C 项目: DTidd/wt
WRectF WPainterPath::controlPointRect(const WTransform& transform) const
{
  if (isEmpty())
    return WRectF();
  else {
    bool identity = transform.isIdentity();

    double minX, minY, maxX, maxY;
    minX = minY = std::numeric_limits<double>::max();
    maxX = maxY = std::numeric_limits<double>::min();

    for (unsigned i = 0; i < segments_.size(); ++i) {
      const Segment& s = segments_[i];

      switch (s.type()) {
      case Segment::MoveTo:
      case Segment::LineTo:
      case Segment::CubicC1:
      case Segment::CubicC2:
      case Segment::CubicEnd:
      case Segment::QuadC:
      case Segment::QuadEnd: {
	if (identity) {
	  minX = std::min(s.x(), minX);
 	  minY = std::min(s.y(), minY);
	  maxX = std::max(s.x(), maxX);
	  maxY = std::max(s.y(), maxY);
	} else {
	  WPointF p = transform.map(WPointF(s.x(), s.y()));
	  minX = std::min(p.x(), minX);
 	  minY = std::min(p.y(), minY);
	  maxX = std::max(p.x(), maxX);
	  maxY = std::max(p.y(), maxY);
	}
	break;
      }
      case Segment::ArcC: {
	const Segment& s2 = segments_[i+1];

	if (identity) {
	  WPointF tl(s.x() - s2.x(), s.y() - s2.y());
	  minX = std::min(tl.x(), minX);
	  minY = std::min(tl.y(), minY);

	  WPointF br(s.x() + s2.x(), s.y() + s2.y());
	  maxX = std::max(br.x(), maxX);
	  maxY = std::max(br.y(), maxY);
	} else {
	  WPointF p1 = transform.map(WPointF(s.x(), s.y()));
	  WPointF p2 = transform.map(WPointF(s2.x(), s2.y()));

	  WPointF tl(p1.x() - p2.x(), p1.y() - p2.y());
	  minX = std::min(tl.x(), minX);
	  minY = std::min(tl.y(), minY);

	  WPointF br(p1.x() + p2.x(), p1.y() + p2.y());
	  maxX = std::max(br.x(), maxX);
	  maxY = std::max(br.y(), maxY);
	}

	i += 2;
	break;
      }
      default:
	assert(false);
      }
    }

    return WRectF(minX, minY, maxX - minX, maxY - minY);
  }
}
示例#20
0
文件: WPolygonArea.C 项目: Sulando/wt
void WPolygonArea::addPoint(double x, double y)
{
  points_.push_back(WPointF(x, y));
  
  repaint();
}
示例#21
0
文件: WPolygonArea.C 项目: Sulando/wt
void WPolygonArea::addPoint(const WPoint& point)
{
  points_.push_back(WPointF(point.x(), point.y()));
  
  repaint();
}
//椭圆在某个方向的点坐标,即从椭圆中心点向某个方向引直线与椭圆的交点
static WPointF point_on_ellipse(const WRectF& r, double radian)
{
	WPointF c = r.center();
	return WPointF(c.x() + r.width() * cos(radian) / 2, c.y() + r.height() * sin(radian) / 2);
}
示例#23
0
文件: PaintBrush.C 项目: ReWeb3D/wt
void PaintBrush::touchStart(const WTouchEvent& e)
{
  Coordinates c = e.touches()[0].widget();
  path_ = WPainterPath(WPointF(c.x, c.y));
}
示例#24
0
文件: PaintBrush.C 项目: ReWeb3D/wt
void PaintBrush::mouseDown(const WMouseEvent& e)
{
  Coordinates c = e.widget();
  path_ = WPainterPath(WPointF(c.x, c.y));
}
示例#25
0
文件: WTransform.C 项目: 913862627/wt
WPointF WTransform::map(const WPointF& p) const
{
  double x, y;
  map(p.x(), p.y(), &x, &y);
  return WPointF(x, y);
}
void WAircraftGlyph::paint(WPainter* painter)
{
	data_type& d = *data();
	painter->setBrush(WBrush(Ws::NoBrush));
	m_cd.aircraftMatrix = painter->worldTransform();
	m_cd.labelMatrix_1 = m_cd.aircraftMatrix.inverted();
	const WMatrix& mapToView = m_cd.aircraftMatrix;
	painter->setWorldTransform(WMatrix());

	WColor symbolColor = d.m_SymbolColor;

	WPointF view_aircraft_pos_f = mapToView.map(d.m_pos);

	static const double R = 10.0;
	static const double RS = 15.0; //draw a bigger circle around, when aircraft is selected

	double x = view_aircraft_pos_f.x();
	double y = view_aircraft_pos_f.y();
	if (d.m_eSymbolType == SYMBOL_COMBINED/*AIRCRAFT_NOR*/)
	{
		
		painter->setPen(WPen(symbolColor));
		if (isSelected())
		{
			painter->drawEllipse(WRectF(x - RS, y - RS, RS * 2, RS * 2));
		}

		//tmp  
		painter->drawEllipse(WRectF(x - R, y - R, R * 2, R * 2));
		painter->drawLine(WLineF(x - R, y, x + R, y));
		painter->drawLine(WLineF(x, y - R, x, y + R));

		//DrawAircraft(painter, view_aircraft_pos);
	}
	else if (d.m_eSymbolType == SYMBOL_PRIMARY)//一次雷达
	{
		painter->setPen(WPen(symbolColor));
		if (isSelected())
		{
			painter->drawEllipse(WRectF(x - RS, y - RS, RS * 2, RS * 2));
		}
		painter->drawLine(WLineF(x - R, y, x + R, y));
		painter->drawLine(WLineF(x, y - R, x, y + R));
	}
	else if (d.m_eSymbolType == SYMBOL_SECONDARY)//二次雷达
	{
		painter->setPen(WPen(symbolColor));
		if (isSelected())
		{
			painter->drawEllipse(WRectF(x - RS, y - RS, RS * 2, RS * 2));
		}
		painter->drawEllipse(WRectF(x - R, y - R, R * 2, R * 2));
	}
	else if (d.m_eSymbolType == SYMBOL_PLAN)//计划航迹
	{
		painter->setPen(WPen(symbolColor));
		if (isSelected())
		{
			painter->drawEllipse(WRectF(x - RS, y - RS, RS * 2, RS * 2));
		}
		painter->drawRect(WRectF(x - R, y - R, R * 2, R * 2));
	}
	else if (d.m_eSymbolType == SYMBOL_COAST)//进入盲区
	{
		painter->setPen(WPen(symbolColor));
		if (isSelected())
		{
			painter->drawEllipse(WRectF(x - RS, y - RS, RS * 2, RS * 2));
		}
		WPen pen;
		pen.setWidth(4);
		pen.setColor(WColor(255, 255, 255));
		painter->setPen(pen);
		painter->drawLine(WWorldLineF(x - R, y, x - R / 2, y));
		painter->drawLine(WWorldLineF(x + R, y, x + R / 2, y));
		painter->drawLine(WWorldLineF(x, y - R, x, y - R / 2));
		painter->drawLine(WWorldLineF(x, y + R, x, y + R / 2));
		pen.setWidth(1);
		pen.setColor(symbolColor);
		painter->setPen(pen);
	}
	else if (d.m_eSymbolType == SYMBOL_SPI)//处于SPI告警状态
	{
		painter->setPen(WPen(symbolColor));
		if (isSelected())
		{
			painter->drawEllipse(WRectF(x - RS, y - RS, RS * 2, RS * 2));
		}
		painter->drawLine(WLineF(x - R, y, x + R, y));
		painter->drawLine(WLineF(x, y - R, x, y + R));
		WPen pen;
		pen.setStyle(Ws::DashLine);
		pen.setColor(WColor(255, 255, 255));
		painter->setPen(pen);
		painter->drawEllipse(WRectF(x - R, y - R, R * 2, R * 2));
		pen.setStyle(Ws::SolidLine);
		pen.setColor(symbolColor);
		painter->setPen(pen);
	}
	else if (d.m_eSymbolType == SYMBOL_VEHICLE)//车辆航迹(实心三角)
	{
		painter->setPen(WPen(symbolColor));
		painter->setBrush(WBrush(symbolColor, Ws::SolidPattern));
		WPointF Tmppoint;
		std::vector<WPointF> vPoints;
		Tmppoint.setXY(x, y - 5);
		vPoints.push_back(Tmppoint);
		Tmppoint.setXY(x - 5, y + 5);
		vPoints.push_back(Tmppoint);
		Tmppoint.setXY(x + 5, y + 5);
		vPoints.push_back(Tmppoint);
		painter->drawPolygon(WWorldPolygonF(vPoints));
		painter->setBrush(WBrush(Ws::NoBrush));

		if (isSelected())
		{
			painter->drawEllipse(WRectF(x - R, y - R, R * 2, R * 2));
		}

	}
	else if (d.m_eSymbolType == SYMBOL_ADSB) // ADSB暂定符号(参考Indra手册)实心菱形
	{
		painter->setPen(WPen(symbolColor));
		painter->setBrush(WBrush(symbolColor, Ws::SolidPattern));
		WPointF Tmppoint;
		std::vector<WPointF> vPoints;
		Tmppoint.setXY(x, y - 5);
		vPoints.push_back(Tmppoint);
		Tmppoint.setXY(x - 5, y);
		vPoints.push_back(Tmppoint);
		Tmppoint.setXY(x, y + 5);
		vPoints.push_back(Tmppoint);
		Tmppoint.setXY(x + 5, y);
		vPoints.push_back(Tmppoint);
		painter->drawPolygon(WWorldPolygonF(vPoints));
		painter->setBrush(WBrush(Ws::NoBrush));

		if (isSelected())
		{
			painter->drawEllipse(WRectF(x - R, y - R, R * 2, R * 2));
		}
	}
	else if (d.m_eSymbolType == SYMBOL_PIC_AIRCRAFT || d.m_eSymbolType == SYMBOL_PIC_HELICOPTER)
	{
		painter->setPen(WPen(symbolColor));
		painter->setBrush(WBrush(symbolColor, Ws::SolidPattern));
		painter->setBrush(WBrush(Ws::NoBrush));
		painter->setRenderHint(Ws::SmoothPixmapTransform);

		WPixmap pixmap(d.m_eSymbolType == SYMBOL_PIC_AIRCRAFT ? ":/plane.png" : ":/helicopter.png");
		WPixmap newPixmap = pixmap.xrotated(-90 + d.m_nHeading, Ws::SmoothTransformation);
		painter->drawPixmap(view_aircraft_pos_f-WPointF(newPixmap.width()/2, newPixmap.height()/2), newPixmap);
	}

	WLineF line(WPointF(), d.m_boundingRect.center());
	if (line.length() > m_sLineMaxLength)
	{
		line.setLength(m_sLineMaxLength);
		WPointF offPoint = line.p2() - d.m_boundingRect.center();
		d.m_boundingRect.translate(offPoint);
		d.m_showRect.translate(offPoint);
	}

	WPointF view_label_pos_f = d.m_boundingRect.bottomLeft() + view_aircraft_pos_f;// aircraft pos + label offset pos
	WPointF offset_f = d.m_showRect.bottomLeft() - d.m_boundingRect.bottomLeft();
	WRectF view_label_rect(WRectF(view_label_pos_f, WSizeF(d.m_boundingRect.width(), d.m_boundingRect.height())));
	//标牌避让
	if (m_sLabelAvoidance)
	{
		const WRectF& r = view_label_rect;
		Mosaic::Instance().Allocate(reinterpret_cast<int>(this), r.left(), r.bottom(), r.right(), r.top());
	}

	// label show rect指标牌边框显示区域,标牌有时候需要显示边框,边框与内容区域可能不一致,如C显示
	WRectF label_show_rect(WRectF(view_label_rect.bottomLeft(), WSizeF(d.m_showRect.width(), d.m_showRect.height())));
	label_show_rect.translate(offset_f);

	//show history
	// 尾迹点访问外部数据,本应该加锁,由于外部默认分配了很大数据存在,且点数据一致增加到默认最大值
	// 内部通过下标访问不存在问题
	// 如外部数据容器变小,就必须得加锁保护
	if (m_sShowHistoryPoint && d.m_vHistory != NULL 
		&& d.m_vHistory->size() > 1)
	{
		size_t n = d.m_vHistory->size() - 1;
		size_t count = (m_sHstNum < n) ? m_sHstNum : n;
		size_t pos = n - 1;
		for (size_t i = 0; i < count; ++i, --pos)
		{
			static const double R = 0.8;
			double dx = 0.00;
			double dy = 0.00;
			mapToView.map((*d.m_vHistory)[pos]->x(), (*d.m_vHistory)[pos]->y(), &dx, &dy);
			painter->drawEllipse(WRectF(dx - R, dy - R, R * 2, R * 2)); //尾迹点
		}
	}

	//show preline
	if (m_sShowPreLine)
	{
		painter->drawLine(WLineF(view_aircraft_pos_f, mapToView.map(d.m_PRLPos))); //预计线
	}

	
	if (d.m_bShowLabel)
	{
		//show linkline (内部包含了外一点与一矩形中心点连线只绘制外一点到矩形边框的算法)
		DrawLabelLine(painter, view_aircraft_pos_f, label_show_rect);

		WPainterProxy proxy(painter);
		painter->setRenderHint(Ws::Antialiasing, false); // 绘制矩形的时候去掉反锯齿,效果更好
		painter->setRenderHint(Ws::TextAntialiasing, false);

		if (d.m_bShowBounding)
		{	
			painter->setPen(d.m_penBounding); // 标牌边框颜色与航迹符号与文本是分开的
			painter->drawRect(label_show_rect);
		}

		//show label
		painter->setFont(m_sLabelFont);

		m_cache_locker.lock();   // 对访问d.m_blocks进行加锁,网络线程在FormatLable的时候会重新组织m_blocks数据,数据需要同步操作
		BOOST_FOREACH(const WBlockData& block, m_blocks)
		{
			painter->setPen(block.m_penText);
			WRectF r = block.m_boundingRect.translated(view_label_pos_f);
			painter->drawText(r, Ws::AlignCenter, block.m_text);
		}
示例#27
0
文件: WPolygonArea.C 项目: Sulando/wt
void WPolygonArea::addPoint(int x, int y)
{
  points_.push_back(WPointF(x, y));
  
  repaint();
}
示例#28
0
bool ShapesWidget::correctlyClicked(const WMouseEvent& me)
{
  return toSelect_->contains(WPointF(me.widget().x, me.widget().y));
}
示例#29
0
文件: WLineF.C 项目: DTidd/wt
WPointF WLineF::p2() const
{
  return WPointF(x2_, y2_);
}
示例#30
0
文件: WPointF.C 项目: hhirsch/wtim
WPointF WPointF::clone() const
{
  return WPointF(*this);
}