// Cria a borda da Viewport [mudar cor/tamanho da linha?]
Viewport::Border::Border(int width, int height) :
    Polygon("_Border") {
    addCoordinate(0,0);
    addCoordinate(width, 0);
    addCoordinate(width, height);
    addCoordinate(0, height);
}
ClipWindow::ClipWindow(double minX_, double maxX_, double minY_, double maxY_):
        Polygon("_border_", GdkRGBA({0,0.9,0})) {

    minX = minX_; maxX = maxX_;
    minY = minY_; maxY = maxY_;

    addCoordinate(minX,minY);
    addCoordinate(maxX,minY);
    addCoordinate(maxX,maxY);
    addCoordinate(minX,maxY);
}
Exemplo n.º 3
0
uint EPANETModelCreator::addJunction(double x, double y, double elevation, double basedemand, std::string demandpattern, std::string tag)
{
	cindex++;
	QString id = QString::number(cindex);

	QString result = "";

	result += id + "\t";
	result += QString::number(elevation) + "\t";
	result += QString::number(basedemand) + "\t";
	result += QString::fromStdString(demandpattern) + "\t";

	(*model[EPANETModelCreator::JUNCTIONS])[id] = result;

	if(tag != "")
	{
		result = "NODE\t";
		result += id + "\t";
		result += QString::fromStdString(tag) + "\t";

		(*model[EPANETModelCreator::TAGS])[id] = result;
	}

	if(!addCoordinate(x,y,QString::number(cindex)))
		return false;

	return cindex;
}
Exemplo n.º 4
0
void PointSetAnnotationTool::mouseMoveEvent(QMouseEvent *event) {
  if (_viewer) {
    if (_generating) {
      QPointF scenePos = _viewer->mapToScene(event->pos());
      if (event->buttons() == Qt::LeftButton) {
        if (QLineF(_viewer->mapFromScene(scenePos), _viewer->mapFromScene(QPointF(_last.getX(), _last.getY()))).length() > 40) {
          addCoordinate(scenePos);
        }
      }
    }
    else if (_startSelectionMove && event->modifiers() == Qt::AltModifier) {
      QPointF scenePos = _viewer->mapToScene(event->pos());
      QSet<QtAnnotation*> selected = _annotationPlugin->getSelectedAnnotations();
      for (QSet<QtAnnotation*>::iterator it = selected.begin(); it != selected.end(); ++it) {
        QPointF delta = (scenePos - _moveStart);
        (*it)->moveCoordinatesBy(Point(delta.x(), delta.y()));
      }
      _moveStart = scenePos;
    }
    else if (_startSelectionMove) {
      QPointF scenePos = _viewer->mapToScene(event->pos());
      PointSetQtAnnotation* active = dynamic_cast<PointSetQtAnnotation*>(_annotationPlugin->getActiveAnnotation());
      if (active && active->getEditable()) {
        int activeSeedPoint = active->getActiveSeedPoint();
        if (activeSeedPoint >= 0) {
          QPointF delta = (scenePos - _moveStart);
          active->moveCoordinateBy(activeSeedPoint, Point(delta.x(), delta.y()));
          _moveStart = scenePos;
        }
      }
    }
    event->accept();
  }
}
Exemplo n.º 5
0
	SplineCurve::SplineCurve(const Coordinates& coords) {
		if (coords.size() < 4) {
			throw CGException("A spline curve must have at least 4 coordinates");
		}

		addCoordinate(coords);
		regeneratePath(0.1);
	}
Exemplo n.º 6
0
	BezierCurve::BezierCurve(const Coordinates& coords) {
		if (coords.size() < 4 || (coords.size() - 4) % 3 != 0) {
			throw CGException("A bezier curve must be defined with 4, 7, 10, 13, 16, ... coordinates");
		}

		addCoordinate(coords);
		regeneratePath(0.1);
	}
Exemplo n.º 7
0
void PointSetAnnotationTool::mousePressEvent(QMouseEvent *event) {
  if (_viewer) {
    QPointF scenePos = _viewer->mapToScene(event->pos());
    if (!_generating) {
      PointSetQtAnnotation* selected = dynamic_cast<PointSetQtAnnotation*>(this->_viewer->itemAt(event->pos()));
      if (selected) {
        if (event->modifiers() != Qt::ControlModifier && event->modifiers() != Qt::AltModifier) {
          _annotationPlugin->clearSelection();
          if (!selected->isSelected()) {
            _annotationPlugin->addAnnotationToSelection(selected);
          }
          else {
            _annotationPlugin->removeAnnotationFromSelection(selected);
          }
        }
        else if (event->modifiers() != Qt::AltModifier) {
          if (!selected->isSelected()) {
            _annotationPlugin->addAnnotationToSelection(selected);
          }
          else {
            _annotationPlugin->removeAnnotationFromSelection(selected);
          }
        }
        if (event->modifiers() == Qt::AltModifier) {
          _startSelectionMove = true;
          _moveStart = scenePos;
        }
        else {
          PointSetQtAnnotation* active = dynamic_cast<PointSetQtAnnotation*>(_annotationPlugin->getActiveAnnotation());
          if (active) {
            if (active == selected) {
              int lastIndexPoint = active->getLastClickedPointIndex();
              if (lastIndexPoint >= 0) {
                active->setActiveSeedPoint(lastIndexPoint);
                _startSelectionMove = true;
                _moveStart = scenePos;
              }
              if (lastIndexPoint < 0) {
                active->clearActiveSeedPoint();
              }
            }
          }
        }
        return;
      }
      else {
        _annotationPlugin->startAnnotation(scenePos.x(), scenePos.y(), name());
        _generating = true;
        _start = Point(scenePos.x(), scenePos.y());
        _last = _start;
      }
    }
    else if (_generating) {
      addCoordinate(scenePos);
    }
    event->accept();
  }
}
Exemplo n.º 8
0
PathObject* OgrFileImport::importPolygonGeometry(MapPart* map_part, OGRFeatureH feature, OGRGeometryH geometry)
{
	auto num_geometries = OGR_G_GetGeometryCount(geometry);
	if (num_geometries < 1)
	{
		++too_few_coordinates;
		return nullptr;
	}
	
	auto outline = OGR_G_ForceToLineString(OGR_G_GetGeometryRef(geometry, 0));
	auto num_points = OGR_G_GetPointCount(outline);
	if (num_points < 3)
	{
		++too_few_coordinates;
		return nullptr;
	}
	
	auto style = OGR_F_GetStyleString(feature);
	auto object = new PathObject(getSymbol(Symbol::Area, style));
	for (int i = 0; i < num_points; ++i)
	{
		object->addCoordinate(toMapCoord(OGR_G_GetX(outline, i), OGR_G_GetY(outline, i)));
	}
	
	for (int g = 1; g < num_geometries; ++g)
	{
		bool start_new_part = true;
		auto hole = /*OGR_G_ForceToLineString*/(OGR_G_GetGeometryRef(geometry, g));
		auto num_points = OGR_G_GetPointCount(hole);
		for (int i = 0; i < num_points; ++i)
		{
			object->addCoordinate(toMapCoord(OGR_G_GetX(hole, i), OGR_G_GetY(hole, i)), start_new_part);
			start_new_part = false;
		}
	}
	
	object->closeAllParts();
	map_part->addObject(object);
	return object;
}
int
CoordinateObject::addOrigDestInfo(OrigDestInfo& info)
{
   byte allowed = ItemTypes::streetSegmentItem;
   
   return addCoordinate(info.getLat(),
                        info.getLon(),
                        0, // All outdatatypes
                        1, // One allowed item type
                        &allowed,
                        info.getAngle());
                        
}
Exemplo n.º 10
0
uint EPANETModelCreator::addReservoir(double x, double y, double head, std::string headpattern)
{
	cindex++;
	QString id = QString::number(cindex);

	QString result = "";
	result += QString::number(cindex) + "\t";
	result += QString::number(head) + "\t";
	result += QString::fromStdString(headpattern) + "\t";

	(*model[EPANETModelCreator::RESERVOIRS])[id]=result;

	if(!addCoordinate(x,y,QString::number(cindex)))
		return false;

	return cindex;
}
Exemplo n.º 11
0
PathObject* OgrFileImport::importLineStringGeometry(MapPart* map_part, OGRFeatureH feature, OGRGeometryH geometry)
{
	geometry = OGR_G_ForceToLineString(geometry);
	
	auto num_points = OGR_G_GetPointCount(geometry);
	if (num_points < 2)
	{
		++too_few_coordinates;
		return nullptr;
	}
	
	auto style = OGR_F_GetStyleString(feature);
	auto object = new PathObject(getSymbol(Symbol::Line, style));
	for (int i = 0; i < num_points; ++i)
	{
		object->addCoordinate(toMapCoord(OGR_G_GetX(geometry, i), OGR_G_GetY(geometry, i)));
	}
	map_part->addObject(object);
	return object;
}
Exemplo n.º 12
0
uint EPANETModelCreator::addTank(double x, double y, double bottomelevation, double initiallevel, double minlevel, double maxlevel, double nominaldiamter, double minvolume, std::string volumecurve)
{
	cindex++;
	QString id = QString::number(cindex);

	QString result = "";

	result += QString::number(cindex) + "\t";
	result += QString::number(bottomelevation) + "\t";
	result += QString::number(initiallevel) + "\t";
	result += QString::number(minlevel) + "\t";
	result += QString::number(maxlevel) + "\t";
	result += QString::number(nominaldiamter) + "\t";
	result += QString::number(minvolume) + "\t";
	result += QString::fromStdString(volumecurve) + "\t";

	(*model[EPANETModelCreator::TANKS])[id]=result;

	if(!addCoordinate(x,y,QString::number(cindex)))
		return false;

	return cindex;
}
Exemplo n.º 13
0
		Point(std::string name, double x, double y) :
            Object(name) { addCoordinate(x,y); }
Exemplo n.º 14
0
		Line(std::string name, const Coordinates& coords) :
            Object(name) { addCoordinate(coords); }
bool RelativeCoordinatePositionerBase::addPoint (const RelativePoint& point)
{
    const bool ok = addCoordinate (point.x);
    return addCoordinate (point.y) && ok;
}
Exemplo n.º 16
0
 Point(std::string name, GdkRGBA color, const Coordinate& p) :
     Object(name,color) { addCoordinate(p); }
Exemplo n.º 17
0
		Point(std::string name, GdkRGBA color, double x, double y) :
            Object(name,color) { addCoordinate(x,y); }
Exemplo n.º 18
0
 Polygon(std::string name, GdkRGBA color, bool filled, const Coordinates& coords) :
     Object(name,color) { _filled = filled; addCoordinate(coords); }
Exemplo n.º 19
0
		Line(std::string name, GdkRGBA color, const Coordinates& coords) :
            Object(name,color) { addCoordinate(coords); }
Exemplo n.º 20
0
		Polygon(std::string name, const Coordinates& coords) :
            Object(name) { _filled = false; addCoordinate(coords); }
Exemplo n.º 21
0
 Point(std::string name, const Coordinate& p) :
     Object(name) { addCoordinate(p); }
Exemplo n.º 22
0
void GnmsCursor::stopCursor(float final_x, float final_y) {
  live = false;

  addCoordinate(final_x, final_y);
}