Ejemplo n.º 1
0
/*! \brief Atualiza os dados remotos de um objeto monitorado, identificado por seu
           índice na lista

Retorna true se conseguiu alterar o objeto monitorado.  Caso contrário,
MOSTRA mensagem de erro e retorna false. Se a atualização remota
foi bem sucedida, copia dados salvos para a lista. 

\param id identificador do objeto monitorado
\param rm   Dados a serem salvos
*/
bool RiskMapList::updateRiskMap(int id, const RiskMap* rm)
{
  RiskMap* oldRm = findMap(id);
  int index = findMapIndex(id);
  assert(oldRm->id() == rm->id());
  
#ifdef OFFLINE_TEST
#else
  int dummy = 0;
  const wsRiskMap& data = rm->data();
  if (_service->layer__editRiskMap(  data.id,
	                                 data.name,
	                                 data.author,
	                                 data.institution,
	                                 data.creationYear,
	                                 data.creationMonth,
	                                 data.creationDay,
	                                 data.expirationYear,
	                                 data.expirationMonth,
	                                 data.expirationDay,
	                                 data.details,
									 data.attrProperties,
									 data.nameAttr,
	                                 dummy) != SOAP_OK)
      return _manager->showModServPlanosError(QObject::tr("Não foi possível atualizar os dados do objeto monitorado."));
#endif

  // objeto monitorado salvo remotamente com sucesso.  Atualiza lista de objetos monitorados
  *oldRm = *rm;

  emit afterUpdateRiskMapList(index, rm->data());

  return true;
}
Ejemplo n.º 2
0
/*! \brief Remove um objeto monitorado, identificado por sua
           chave (id) no banco

Retorna true se conseguiu remover o objeto monitorado.  Caso contrário,
MOSTRA mensagem de erro e retorna false. 
*/
bool RiskMapList::deleteRiskMap(int id)
{
  RiskMap* rm = findMap(id);
  int index = findMapIndex(id);
  
#ifdef OFFLINE_TEST
#else
  int dummy = 0;
  if(_service->layer__deleteRiskMap(id, dummy) != SOAP_OK)
    return _manager->showModServPlanosError(QObject::tr("Não foi possível remover o objeto monitorado."));
#endif

  emit beforeDeleteRiskMapList(index, rm->data());

  // Conseguimos apagar o objeto monitorado do servidor remoto.  Remove da lista
  removeAt(index);
  delete rm;


  return true;
}
Ejemplo n.º 3
0
/* addEndpoint:
 * Add node to graph representing spline end point p inside obstruction obs_id.
 * For each side of obstruction, add edge from p to corresponding triangle.
 * The node id of the new node in the graph is v_id.
 * If p lies on the side of its node (sides != 0), we limit the triangles
 * to those within 45 degrees of each side of the natural direction of p.
 */
static void addEndpoint(router_t * rtr, pointf p, node_t* v, int v_id, int sides)
{
    int obs_id = ND_lim(v);
    int starti = rtr->obs[obs_id];
    int endi = rtr->obs[obs_id + 1];
    pointf* pts = rtr->ps;
    int i, t;
    double d;
    pointf vr, v0, v1;

    switch (sides) {
    case TOP :
	vr = add_pointf (p, north);
	v0 = add_pointf (p, northwest);
	v1 = add_pointf (p, northeast);
	break;
    case TOP|RIGHT :
	vr = add_pointf (p, northeast);
	v0 = add_pointf (p, north);
	v1 = add_pointf (p, east);
	break;
    case RIGHT :
	vr = add_pointf (p, east);
	v0 = add_pointf (p, northeast);
	v1 = add_pointf (p, southeast);
	break;
    case BOTTOM|RIGHT :
	vr = add_pointf (p, southeast);
	v0 = add_pointf (p, east);
	v1 = add_pointf (p, south);
	break;
    case BOTTOM :
	vr = add_pointf (p, south);
	v0 = add_pointf (p, southeast);
	v1 = add_pointf (p, southwest);
	break;
    case BOTTOM|LEFT :
	vr = add_pointf (p, southwest);
	v0 = add_pointf (p, south);
	v1 = add_pointf (p, west);
	break;
    case LEFT :
	vr = add_pointf (p, west);
	v0 = add_pointf (p, southwest);
	v1 = add_pointf (p, northwest);
	break;
    case TOP|LEFT :
	vr = add_pointf (p, northwest);
	v0 = add_pointf (p, west);
	v1 = add_pointf (p, north);
	break;
    case 0 :
	break;
    default :
	assert (0);
	break;
    }

    rtr->tg->nodes[v_id].ne = 0;
    rtr->tg->nodes[v_id].ctr = p;
    for (i = starti; i < endi; i++) {
	ipair seg;
	seg.i = i;
	if (i < endi - 1)
	    seg.j = i + 1;
	else
	    seg.j = starti;
	t = findMap(rtr->trimap, seg.i, seg.j);
	if (sides && !inCone (v0, p, v1, pts[seg.i]) && !inCone (v0, p, v1, pts[seg.j]) && !raySeg(p,vr,pts[seg.i],pts[seg.j]))
	    continue;
	d = DIST(p, (rtr->tg->nodes + t)->ctr);
	addTriEdge(rtr->tg, v_id, t, d, seg);
    }
}