Ejemplo n.º 1
0
void GeoTreeModel::addChildren(GeoObjectListItem* plyList,
                               const GeoLib::PolylineVec* polyline_vec,
                               size_t start_index,
                               size_t end_index)
{
	const std::vector<GeoLib::Polyline*> lines = *(polyline_vec->getVector());

	for (size_t i = start_index; i < end_index; i++)
	{
		QList<QVariant> line_data;
		std::string ply_name("");
		if (polyline_vec->getNameOfElementByID(i, ply_name))
			line_data << "Line " + QString::number(i) << QString::fromStdString(ply_name) << "" << "";
		else line_data << "Line " + QString::number(i) << "" << "" << "";

		const GeoLib::Polyline &line(*(lines[i]));
		GeoTreeItem* lineItem(new GeoTreeItem(line_data, plyList, &line));
		plyList->appendChild(lineItem);

		int nPoints = static_cast<int>(lines[i]->getNumberOfPoints());
		for (int j = 0; j < nPoints; j++)
		{
			const GeoLib::Point pnt(*(line.getPoint(j)));
			QList<QVariant> pnt_data;
			pnt_data << static_cast<int>(line.getPointID(j))
			         << QString::number(pnt[0], 'f')
			         << QString::number(pnt[1], 'f')
			         << QString::number(pnt[2], 'f');
			TreeItem* child(new TreeItem(pnt_data, lineItem));
			lineItem->appendChild(child);
		}
	}
	std::cout << end_index - start_index << " polylines added." << std::endl;
}
Ejemplo n.º 2
0
void Checker::finishActiveSegment (const DocumentModelCoords &modelCoords,
                                   const QPointF &posStartScreen,
                                   const QPointF &posEndScreen,
                                   double yFrom,
                                   double yTo,
                                   const Transformation &transformation,
                                   SideSegments &sideSegments) const
{
  LOG4CPP_INFO_S ((*mainCat)) << "Checker::finishActiveSegment"
                              << " posStartScreen=" << QPointFToString (posStartScreen).toLatin1().data()
                              << " posEndScreen=" << QPointFToString (posEndScreen).toLatin1().data()
                              << " yFrom=" << yFrom
                              << " yTo=" << yTo;

  QGraphicsItem *item;
  if ((modelCoords.coordsType() == COORDS_TYPE_POLAR) &&
      (yFrom == yTo)) {

    // Linear cartesian radius
    double radiusLinearCartesian = yFrom;
    if (modelCoords.coordScaleYRadius() == COORD_SCALE_LOG) {
      radiusLinearCartesian = transformation.logToLinearRadius(yFrom,
                                                               modelCoords.originRadius());
    } else {
      radiusLinearCartesian -= modelCoords.originRadius();
    }

    // Draw along an arc since this is a side of constant radius, and we have polar coordinates
    item = ellipseItem (transformation,
                        radiusLinearCartesian,
                        posStartScreen,
                        posEndScreen);

  } else {

    // Draw straight line
    item = lineItem (posStartScreen,
                     posEndScreen);
  }

  sideSegments.push_back (item);
  bindItemToScene (item);
}
void GridLineFactory::finishActiveGridLine (const QPointF &posStartScreen,
                                            const QPointF &posEndScreen,
                                            double yFrom,
                                            double yTo,
                                            const Transformation &transformation,
                                            GridLine &gridLine) const
{
  LOG4CPP_DEBUG_S ((*mainCat)) << "GridLineFactory::finishActiveGridLine"
                               << " posStartScreen=" << QPointFToString (posStartScreen).toLatin1().data()
                               << " posEndScreen=" << QPointFToString (posEndScreen).toLatin1().data()
                               << " yFrom=" << yFrom
                               << " yTo=" << yTo;

  QGraphicsItem *item;
  if ((m_modelCoords.coordsType() == COORDS_TYPE_POLAR) &&
      (yFrom == yTo)) {

    // Linear cartesian radius
    double radiusLinearCartesian = yFrom;
    if (m_modelCoords.coordScaleYRadius() == COORD_SCALE_LOG) {
      radiusLinearCartesian = transformation.logToLinearRadius(yFrom,
                                                               m_modelCoords.originRadius());
    } else {
      radiusLinearCartesian -= m_modelCoords.originRadius();
    }

    // Draw along an arc since this is a side of constant radius, and we have polar coordinates
    item = ellipseItem (transformation,
                        radiusLinearCartesian,
                        posStartScreen,
                        posEndScreen);

  } else {

    // Draw straight line
    item = lineItem (posStartScreen,
                     posEndScreen);
  }

  gridLine.add (item);
  bindItemToScene (item);
}
Ejemplo n.º 4
0
void GeoTreeModel::addChildren(GeoObjectListItem* plyList,
                               GeoLib::PolylineVec const& polyline_vec,
                               size_t start_index,
                               size_t end_index)
{
	const std::vector<GeoLib::Polyline*> lines = *(polyline_vec.getVector());

	for (size_t i = start_index; i < end_index; i++)
	{
		QList<QVariant> line_data;
		line_data.reserve(4);
		line_data << "Line " + QString::number(i) << "" << "" << "";

		const GeoLib::Polyline &line(*(lines[i]));
		GeoTreeItem* lineItem(new GeoTreeItem(line_data, plyList, &line));
		plyList->appendChild(lineItem);

		int nPoints = static_cast<int>(lines[i]->getNumberOfPoints());
		for (int j = 0; j < nPoints; j++)
		{
			const GeoLib::Point pnt(*(line.getPoint(j)));
			QList<QVariant> pnt_data;
			pnt_data.reserve(4);
			pnt_data << static_cast<int>(line.getPointID(j))
			         << QString::number(pnt[0], 'f')
			         << QString::number(pnt[1], 'f')
			         << QString::number(pnt[2], 'f');

			lineItem->appendChild(new TreeItem(pnt_data, lineItem));
		}
	}

	for (auto pnt = polyline_vec.getNameIDMapBegin(); pnt != polyline_vec.getNameIDMapEnd(); ++pnt)
		QVariant pnt_data (plyList->child(pnt->second)->setData(1, QString::fromStdString(pnt->first)));

	INFO("%d polylines added.", end_index - start_index);
}
Ejemplo n.º 5
0
bool Plugin::render(QGraphicsView *graphicsView, QGraphicsItem *parent)
{
	qDebug() << "Painting the Scenario";
	
	m_itemGroup = new QGraphicsItemGroup();
	
	while (!m_drawStack.isEmpty()) {
		const Plugin::Command *cmd = m_drawStack.front();
		m_drawStack.pop_front();
		
		QStringList tokList = cmd->values().split(':', QString::SkipEmptyParts);
		bool ret = true; // return value
		
		switch (cmd->drawCommand()) {
			case Plugin::Command::Pen: 
				ret = setCurPen(tokList);
				break;
				
				// added brackets to delimit the variables scope
				// thats not necessary on case Pen.
			case Plugin::Command::Rect: {
				QGraphicsRectItem *rect = rectItem(tokList);

				if (rect)
					m_itemGroup->addToGroup(rect);
				else
					ret = false;
			}
				break;
				
			case Plugin::Command::Line: {
				QGraphicsLineItem *line = lineItem(tokList);

				if (line)
					m_itemGroup->addToGroup(line);
				else
					ret = false;
			}
				break;
				
			case Plugin::Command::Ellipse: {
				QGraphicsEllipseItem *ellipse = ellipseItem(tokList);

				if (ellipse)
					m_itemGroup->addToGroup(ellipse);
				else
					ret = false;
			}
				break;
		}
		
		if (!ret) {
			delete m_itemGroup; // force to delete the group
			return false;
		}
	}
	
	if (parent)
		m_itemGroup->setParentItem(parent);
	
	m_itemGroup->setPos(m_point);
	graphicsView->scene()->addItem(m_itemGroup);
	
	return true;
}