/*! \brief Check if a bounding box is visible on the screen. * \par Function Description * This function checks if a given bounding box is visible on the screen. * * WARNING: top and bottom are mis-named in world-coords, * top is the smallest "y" value, and bottom is the largest. * Be careful! This doesn't correspond to what you'd expect. * * \param [in] w_current The GSCHEM_TOPLEVEL object. * \param [in] wleft Left coordinate of the bounding box. * \param [in] wtop Top coordinate of the bounding box. * \param [in] wright Right coordinate of the bounding box. * \param [in] wbottom Bottom coordinate of the bounding box. * \return TRUE if bounding box is visible, FALSE otherwise */ int visible (GSCHEM_TOPLEVEL *w_current, int wleft, int wtop, int wright, int wbottom) { int visible=FALSE; /* don't do object clipping if this is false */ if (!w_current->toplevel->object_clipping) { return(TRUE); } visible = clip_nochange (w_current, wleft, wtop, wright, wtop); #if DEBUG printf("vis1 %d\n", visible); #endif if (!visible) { visible = clip_nochange (w_current, wleft, wbottom, wright, wbottom); } else { return(visible); } #if DEBUG printf("vis2 %d\n", visible); #endif if (!visible) { visible = clip_nochange (w_current, wleft, wtop, wleft, wbottom); } else { return(visible); } #if DEBUG printf("vis3 %d\n", visible); #endif if (!visible) { visible = clip_nochange (w_current, wright, wtop, wright, wbottom); } else { return(visible); } #if DEBUG printf("vis4 %d\n", visible); #endif #if DEBUG printf("%d %d %d\n", wleft, w_current->toplevel->page_current->top, wright); printf("%d %d %d\n", wtop, w_current->toplevel->page_current->top, wbottom); printf("%d %d %d\n", wleft, w_current->toplevel->page_current->right, wright); printf("%d %d %d\n", wtop, w_current->toplevel->page_current->bottom, wbottom); #endif /* * now check to see if bounding box encompasses the entire viewport. * We only need to test if one point on the screen clipping boundary * is indide the bounding box of the object. */ if (w_current->toplevel->page_current->left >= wleft && w_current->toplevel->page_current->left <= wright && w_current->toplevel->page_current->top >= wtop && w_current->toplevel->page_current->top <= wbottom ) { visible = 1; } #if DEBUG printf("vis5 %d\n", visible); #endif return(visible); }
/*! \brief Check if a bounding box is visible on the screen. * \par Function Description * This function checks if a given bounding box is visible on the screen. * * WARNING: top and bottom are mis-named in world-coords, * top is the smallest "y" value, and bottom is the largest. * Be careful! This doesn't correspond to what you'd expect. * * \param [in] w_current The GschemToplevel object. * \param [in] wleft Left coordinate of the bounding box. * \param [in] wtop Top coordinate of the bounding box. * \param [in] wright Right coordinate of the bounding box. * \param [in] wbottom Bottom coordinate of the bounding box. * \return TRUE if bounding box is visible, FALSE otherwise */ int visible (GschemToplevel *w_current, int wleft, int wtop, int wright, int wbottom) { int visible=FALSE; GschemPageGeometry *geometry = gschem_page_view_get_page_geometry (gschem_toplevel_get_current_page_view (w_current)); visible = clip_nochange (geometry, wleft, wtop, wright, wtop); #if DEBUG printf("vis1 %d\n", visible); #endif if (!visible) { visible = clip_nochange (geometry, wleft, wbottom, wright, wbottom); } else { return(visible); } #if DEBUG printf("vis2 %d\n", visible); #endif if (!visible) { visible = clip_nochange (geometry, wleft, wtop, wleft, wbottom); } else { return(visible); } #if DEBUG printf("vis3 %d\n", visible); #endif if (!visible) { visible = clip_nochange (geometry, wright, wtop, wright, wbottom); } else { return(visible); } #if DEBUG printf("vis4 %d\n", visible); #endif #if DEBUG printf("%d %d %d\n", wleft, geometry->viewport_top, wright); printf("%d %d %d\n", wtop, geometry->viewport_top, wbottom); printf("%d %d %d\n", wleft, geometry->viewport_right, wright); printf("%d %d %d\n", wtop, geometry->viewport_bottom, wbottom); #endif /* * now check to see if bounding box encompasses the entire viewport. * We only need to test if one point on the screen clipping boundary * is indide the bounding box of the object. */ if (geometry->viewport_left >= wleft && geometry->viewport_left <= wright && geometry->viewport_top >= wtop && geometry->viewport_top <= wbottom ) { visible = 1; } #if DEBUG printf("vis5 %d\n", visible); #endif return(visible); }