/*! \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(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y) { 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; w_current->inside_action = 1; }
/*! \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; }
/*! \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; }