Пример #1
0
void blocked_dialog::OnOK( wxCommandEvent& event )
{   
    // Prevent ending the dialog if the exclusion box is empty.
    wxString exclusion_string;

    exclusion_string = XRCCTRL( *this, "blocked_dialog_exclusion_textctrl", wxTextCtrl )->GetValue();

    if ( exclusion_string == "" ) 
    {
         wxMessageDialog message_dlg( this, _( "You must enter some text in the \"Item to block\" edit box." ),
                                      _( "Enter exclusion" ),
                                      wxOK|wxICON_INFORMATION  );
        message_dlg.ShowModal();
        // Abort the OnOK function
        return;                   
    }
    
    // Get rid of the modal dialog. Not transferring any info from this modal's control
    // to a parent dialog, so don't have to bother with wxWindow::Validate or 
    // wxWindow::TransferDataFromWindow.    
    EndModal( wxID_OK );
}
Пример #2
0
void map_t::node_move(map_item_t *map_item, const osm2go_platform::screenpos &p)
{
  osm_t::ref osm = appdata.project->osm;

  assert(map_item->object.type == object_t::NODE);
  node_t *node = map_item->object.node;

  printf("released dragged node #" ITEM_ID_FORMAT "\n", node->id);
  printf("  was at %d %d (%f %f)\n",
	 node->lpos.x, node->lpos.y,
	 node->pos.lat, node->pos.lon);

  /* check if it was dropped onto another node */
  bool joined_with_touchnode = false;

  if(touchnode != nullptr) {
    node_t *tn = touchnode_get_node();

    printf("  dropped onto node #" ITEM_ID_FORMAT "\n", tn->id);

    if(osm2go_platform::yes_no(_("Join nodes?"),
                               _("Do you want to join the dragged node with the one you dropped it on?"),
                               MISC_AGAIN_ID_JOIN_NODES)) {
      /* the touchnode vanishes and is replaced by the node the */
      /* user dropped onto it */
      joined_with_touchnode = true;
      unsigned int ways2join_cnt = 0;

      // only offer to join ways if they come from the different nodes, not
      // if e.g. one node has 2 ways and the other has none
      way_t *ways2join[2] = { nullptr, nullptr };
      if(node->ways > 0 && tn->ways > 0)
        ways2join_cnt = node->ways + tn->ways;

      osm_t::mergeResult<node_t> mr = osm->mergeNodes(node, tn, ways2join);
      // make sure the object marked as selected is the surviving node
      selected.object = node = mr.obj;

      /* and open dialog to resolve tag collisions if necessary */
      if(mr.conflict)
        message_dlg(_("Node tag conflict"),
                    _("The resulting node contains some conflicting tags. Please solve these."));

      /* check whether this will also join two ways */
      printf("  checking if node is end of way\n");

      if(ways2join_cnt > 2) {
        message_dlg(_("Too many ways to join"),
                    _("More than two ways that contain this node. Joining more "
                      "than two ways is not yet implemented, sorry"));
      } else if(ways2join_cnt == 2 && ways2join[0] != nullptr &&
                osm2go_platform::yes_no(_("Join ways?"),
                         _("Do you want to join the dragged way with the one you dropped it on?"),
                                        MISC_AGAIN_ID_JOIN_WAYS)) {
        printf("  about to join ways #" ITEM_ID_FORMAT " and #" ITEM_ID_FORMAT "\n",
               ways2join[0]->id, ways2join[1]->id);

        if(osm->mergeWays(ways2join[0], ways2join[1], this).conflict)
          message_dlg(_("Way tag conflict"),
                      _("The resulting way contains some conflicting tags. Please solve these."));
      }
    }
  }

  /* the node either wasn't dropped into another one (touchnode) or */
  /* the user didn't want to join the nodes */
  if(!joined_with_touchnode) {

    /* finally update dragged nodes position */

    /* convert mouse position to canvas (world) position */
    lpos_t pos = canvas->window2world(p);
    if(!osm->bounds.contains(pos)) {
      map_t::outside_error();
      return;
    }

    /* convert screen position to lat/lon */
    node->pos = pos.toPos(osm->bounds);

    /* convert pos back to lpos to see rounding errors */
    node->lpos = node->pos.toLpos(osm->bounds);

    printf("  now at %d %d (%f %f)\n",
	   node->lpos.x, node->lpos.y, node->pos.lat, node->pos.lon);
  }

  /* now update the visual representation of the node */
  draw(node);

  /* visually update ways, node is part of */
  if(node->ways > 0)
    std::for_each(osm->ways.begin(), osm->ways.end(), redraw_way(node, this));

  /* and mark the node as dirty */
  node->flags |= OSM_FLAG_DIRTY;

  /* update highlight */
  highlight_refresh();
}
Пример #3
0
void map_t::way_add_ok() {
  osm_t::ref osm = appdata.project->osm;

  assert(osm);
  assert(action.way != nullptr);

  /* transfer all nodes that have been created for this way */
  /* into the node chain */

  /* (their way count will be 0 after removing the way) */
  node_chain_t &chain = action.way->node_chain;
  std::for_each(chain.begin(), chain.end(), map_draw_nodes(this));

  /* attach to existing way if the user requested so */
  if(action.extending != nullptr) {
    // this is triggered when the user started with extending an existing way
    // since the merged way is a temporary one there are no relation memberships
    // and no background item
    assert(background_items.find(action.way) == background_items.end());
    action.extending->merge(action.way, osm, this);

    action.way = action.extending;
  } else {
    /* now move the way itself into the main data structure */
    osm->way_attach(action.way);
  }

  /* we might already be working on the "ends_on" way as we may */
  /* be extending it. Joining the same way doesn't make sense. */
  if(action.ends_on == action.way) {
    printf("  the new way ends on itself -> don't join itself\n");
    action.ends_on = nullptr;
  } else if(action.ends_on != nullptr && osm2go_platform::yes_no(_("Join way?"),
                                           _("Do you want to join the way present at this location?"),
                                                          MISC_AGAIN_ID_EXTEND_WAY_END)) {
    printf("  this new way ends on another way\n");
    // this is triggered when the new way ends on an existing way, this can
    // happen even if an existing way was extended before

    /* this is slightly more complex as this time two full tagged */
    /* ways may be involved as the new way may be an extended existing */
    /* way being connected to another way. This happens if you connect */
    /* two existing ways using a new way between them */

    osm_t::mergeResult<way_t> mr = osm->mergeWays(action.way, action.ends_on, this);
    action.way = mr.obj;
    action.ends_on = nullptr;

    if(mr.conflict)
      message_dlg(_("Way tag conflict"),
                  _("The resulting way contains some conflicting tags. Please solve these."));
  }

  /* draw the updated way */
  draw(action.way);

  select_way(action.way);

  action.way = nullptr;

  /* let the user specify some tags for the new way */
  info_selected();
}