Exemplo n.º 1
0
/*! \private
 *  \brief Get a property
 *
 *  \param [in]     object
 *  \param [in]     param_id
 *  \param [in,out] value
 *  \param [in]     pspec
 */
static void
get_property (GObject *object, guint param_id, GValue *value, GParamSpec *pspec)
{
  GschemOptions *options = GSCHEM_OPTIONS (object);

  switch (param_id) {
    case PROP_GRID_MODE:
      g_value_set_int (value, gschem_options_get_grid_mode (options));
      break;

    case PROP_MAGNETIC_NET_MODE:
      g_value_set_boolean (value, gschem_options_get_magnetic_net_mode (options));
      break;

    case PROP_NET_RUBBER_BAND_MODE:
      g_value_set_boolean (value, gschem_options_get_net_rubber_band_mode (options));
      break;

    case PROP_SNAP_MODE:
      g_value_set_int (value, gschem_options_get_snap_mode (options));
      break;

    case PROP_SNAP_SIZE:
      g_value_set_int (value, gschem_options_get_snap_size (options));
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
  }
}
Exemplo n.º 2
0
/*! \private
 *  \brief Update the net rubber band mode widget with the current value
 *
 *  \param [in,out] widget This widget
 */
static void
update_magnetic_net_mode_widget (GschemOptionsWidget *widget)
{
  g_return_if_fail (widget != NULL);

  if (widget->options != NULL) {
    GschemToplevel *w_current;

    g_object_get (widget, "gschem-toplevel", &w_current, NULL);

    g_return_if_fail (w_current != NULL);

    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget->magnetic_net_widget),
                                  gschem_options_get_magnetic_net_mode (w_current->options));
  }
}
Exemplo n.º 3
0
/*! \brief callback function to draw a net marker in magnetic mode
 *  \par Function Description
 *  If the mouse is moved, this function is called to update the
 *  position of the magnetic marker.
 *  If the controllkey is pressed the magnetic marker follows the mouse.
 */
void o_net_start_magnetic(GschemToplevel *w_current, int w_x, int w_y)
{
  if (!(gschem_options_get_magnetic_net_mode (w_current->options))) {
    return;
  }

  o_net_invalidate_rubber (w_current);

  if (w_current->CONTROLKEY) {
    w_current->magnetic_wx = w_x;
    w_current->magnetic_wy = w_y;
  }
  else {
    o_net_find_magnetic(w_current, w_x, w_y);
  }

  o_net_invalidate_rubber (w_current);
  w_current->rubber_visible = 1;
}
Exemplo n.º 4
0
/*! \todo Finish function documentation!!!
 *  \brief
 *  \par Function Description
 *
 */
void o_net_invalidate_rubber (GschemToplevel *w_current)
{
  int size = 0, magnetic_halfsize;
  int magnetic_x, magnetic_y;
  gboolean magnetic_net_mode;

  g_return_if_fail (w_current != NULL);

  GschemPageView *page_view = gschem_toplevel_get_current_page_view (w_current);
  g_return_if_fail (page_view != NULL);

  gschem_page_view_WORLDtoSCREEN (page_view,
                                  w_current->magnetic_wx, w_current->magnetic_wy,
                                  &magnetic_x, &magnetic_y);

  size = gschem_page_view_SCREENabs (page_view, NET_WIDTH);

  magnetic_net_mode = gschem_options_get_magnetic_net_mode (w_current->options);

  if (magnetic_net_mode) {
    if (w_current->magnetic_wx != -1 && w_current->magnetic_wy != -1) {
      magnetic_halfsize = max (4 * size, MAGNETIC_HALFSIZE);

      o_invalidate_rect (w_current, magnetic_x - magnetic_halfsize,
                                    magnetic_y - magnetic_halfsize,
                                    magnetic_x + magnetic_halfsize,
                                    magnetic_y + magnetic_halfsize);
    }
  }

  gschem_page_view_invalidate_world_rect (page_view,
                                          w_current->first_wx,
                                          w_current->first_wy,
                                          w_current->second_wx,
                                          w_current->second_wy);

  gschem_page_view_invalidate_world_rect (page_view,
                                          w_current->second_wx,
                                          w_current->second_wy,
                                          w_current->third_wx,
                                          w_current->third_wy);
}
Exemplo n.º 5
0
/*! \brief draw rubbernet lines to the gc
 *  \par Function Description
 *  This function draws the rubbernets to the graphic context
 */
void
o_net_draw_rubber(GschemToplevel *w_current, EdaRenderer *renderer)
{
  int size = NET_WIDTH, w_magnetic_halfsize;
  cairo_t *cr = eda_renderer_get_cairo_context (renderer);
  GArray *color_map = eda_renderer_get_color_map (renderer);
  int flags = eda_renderer_get_cairo_flags (renderer);
  gboolean magnetic_net_mode;

  g_return_if_fail (w_current != NULL);

  GschemPageView *page_view = gschem_toplevel_get_current_page_view (w_current);
  g_return_if_fail (page_view != NULL);

  eda_cairo_set_source_color (cr, SELECT_COLOR, color_map);

  magnetic_net_mode = gschem_options_get_magnetic_net_mode (w_current->options);

  if (magnetic_net_mode) {
    if (w_current->magnetic_wx != -1 && w_current->magnetic_wy != -1) {
      w_magnetic_halfsize = max (4 * size,
                                 gschem_page_view_WORLDabs (page_view, MAGNETIC_HALFSIZE));
      eda_cairo_arc (cr, flags, size,
                     w_current->magnetic_wx, w_current->magnetic_wy,
                     w_magnetic_halfsize, 0, 360);
    }
  }

  /* Primary line */
  eda_cairo_line (cr, flags, END_NONE, size,
                  w_current->first_wx,  w_current->first_wy,
                  w_current->second_wx, w_current->second_wy);

  /* Secondary line */
  eda_cairo_line (cr, flags, END_NONE, size,
                     w_current->second_wx, w_current->second_wy,
                     w_current->third_wx,  w_current->third_wy);

  eda_cairo_stroke (cr, flags, TYPE_SOLID, END_NONE, size, -1, -1);
}
Exemplo n.º 6
0
/*! \brief erase and redraw the rubber lines when drawing a net
 *  \par Function Description
 *  This function draws the rubbernet lines when drawing a net.
 */
void o_net_motion (GschemToplevel *w_current, int w_x, int w_y)
{
  int ortho, horizontal, quadrant;
  gboolean magnetic_net_mode;

  g_return_if_fail (w_current != NULL);
  g_assert( w_current->inside_action != 0 );

  magnetic_net_mode = gschem_options_get_magnetic_net_mode (w_current->options);

  /* Orthognal mode enabled when Control Key is NOT pressed or
     if we are using magnetic mode */
  ortho = !w_current->CONTROLKEY || magnetic_net_mode;

  if (w_current->rubber_visible)
    o_net_invalidate_rubber (w_current);

  if (magnetic_net_mode) {
    if (w_current->CONTROLKEY) {
      /* set the magnetic marker position to current xy if the
	 controlkey is pressed. Thus the net will not connect to
	 the closest net if we finish the net drawing */
      w_current->magnetic_wx = w_x;
      w_current->magnetic_wy = w_y;
    }
    else {
      o_net_find_magnetic(w_current, w_x, w_y);
    }
  }

  w_current->second_wx = w_x;
  w_current->second_wy = w_y;

  /* In orthogonal mode secondary line is the same as the first */
  if (!ortho) {
      w_current->third_wx = w_current->second_wx;
      w_current->third_wy = w_current->second_wy;
  }
  /* If you press the control key then you can draw non-ortho nets */
  else {
    if (w_current->second_wy > w_current->first_wy)
      quadrant = w_current->second_wx > w_current->first_wx ? QUADRANT1: QUADRANT2;
    else
      quadrant = w_current->second_wx > w_current->first_wx ? QUADRANT4: QUADRANT3;

    horizontal = w_current->net_direction & quadrant;

    if (!w_current->SHIFTKEY)
      horizontal = !horizontal;

    /* calculate the co-ordinates necessary to draw the lines*/
    /* Pressing the shift key will cause the vertical and horizontal lines to switch places */
    if ( horizontal ) {
      w_current->second_wy = w_current->first_wy;
      w_current->third_wx = w_current->second_wx;
      w_current->third_wy = w_y;
    } else {
      w_current->second_wx = w_current->first_wx;
      w_current->third_wx = w_x;
      w_current->third_wy = w_current->second_wy;
    }
  }

  o_net_invalidate_rubber (w_current);
  w_current->rubber_visible = 1;
}