Changeset 62026


Ignore:
Timestamp:
Sep 17, 2014, 3:43:22 PM (10 years ago)
Author:
glynn
Message:

Change handling of display frame, graphical clip window

Replace D_get_window with D_get_frame
Add D_get_clip_window, D_set_clip_window
Add D_set_clip_window_to_map_window, D_set_clip_window_to_screen_window
Store initial frame size within display library
Change D_setup* functions to set graphical clip window

Location:
grass/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • grass/trunk/display/d.info/main.c

    r52861 r62026  
    7272   
    7373    if (rflag->answer || dflag->answer || fflag->answer)
    74         D_get_window(&t, &b, &l, &r);
     74        D_get_frame(&t, &b, &l, &r);
    7575
    7676
  • grass/trunk/include/defs/display.h

    r49183 r62026  
    150150int D_save_command(const char *);
    151151
    152 void D_get_window(double *, double *, double *, double *);
    153 
    154152void D__erase(void);
    155153
     
    163161void D_font_info(char ***, int *);
    164162
     163void D_get_clip_window(double *, double *, double *, double *);
     164void D_set_clip_window(double, double, double, double);
     165void D_get_frame(double *, double *, double *, double *);
     166void D_set_clip_window_to_map_window(void);
     167void D_set_clip_window_to_screen_window(void);
     168
    165169#endif /* GRASS_DISPLAYDEFS_H */
  • grass/trunk/lib/display/r_raster.c

    r60215 r62026  
    3737static int read_env_file(const char *);
    3838
     39static struct {
     40    double t, b, l, r;
     41} screen;
     42
    3943static void init(void)
    4044{
     
    6165
    6266    if (frame) {
    63         double t, b, l, r;
    64         sscanf(frame, "%lf,%lf,%lf,%lf", &t, &b, &l, &r);
    65         COM_Set_window(t, b, l, r);
     67        sscanf(frame, "%lf,%lf,%lf,%lf", &screen.t, &screen.b, &screen.l, &screen.r);
     68        COM_Set_window(screen.t, screen.b, screen.l, screen.r);
    6669    }
     70    else
     71        COM_Get_window(&screen.t, &screen.b, &screen.l, &screen.r);
    6772}
    6873
     
    267272
    268273/*!
    269   \brief Get clipping frame
    270  
    271   \param[out] t top
    272   \param[out] b bottom
    273   \param[out] l left
    274   \param[out] r right
    275 */
    276 void D_get_window(double *t, double *b, double *l, double *r)
    277 {
    278     return COM_Get_window(t, b, l, r);
    279 }
    280 
    281 /*!
    282274  \brief Draw text
    283275 
     
    335327    COM_Font_info(list, count);
    336328}
     329
     330/*!
     331 * \brief get graphical clipping window
     332 *
     333 * Queries the graphical clipping window (origin is top right)
     334 *
     335 *  \param[out] t top edge of clip window
     336 *  \param[out] b bottom edge of clip window
     337 *  \param[out] l left edge of clip window
     338 *  \param[out] r right edge of clip window
     339 *  \return ~
     340 */
     341
     342void D_get_clip_window(double *t, double *b, double *l, double *r)
     343{
     344    COM_Get_window(t, b, l, r);
     345}
     346
     347/*!
     348 * \brief set graphical clipping window
     349 *
     350 * Sets the graphical clipping window to the specified rectangle
     351 *  (origin is top right)
     352 *
     353 *  \param t top edge of clip window
     354 *  \param b bottom edge of clip window
     355 *  \param l left edge of clip window
     356 *  \param r right edge of clip window
     357 *  \return ~
     358 */
     359
     360void D_set_clip_window(double t, double b, double l, double r)
     361{
     362    if (t < screen.t) t = screen.t;
     363    if (b > screen.b) b = screen.b;
     364    if (l < screen.l) l = screen.l;
     365    if (r > screen.r) r = screen.r;
     366
     367    COM_Set_window(t, b, l, r);
     368}
     369
     370/*!
     371 * \brief get graphical window (frame)
     372 *
     373 * Queries the graphical frame (origin is top right)
     374 *
     375 *  \param[out] t top edge of frame
     376 *  \param[out] b bottom edge of frame
     377 *  \param[out] l left edge of frame
     378 *  \param[out] r right edge of frame
     379 *  \return ~
     380 */
     381
     382void D_get_frame(double *t, double *b, double *l, double *r)
     383{
     384    *t = screen.t;
     385    *b = screen.b;
     386    *l = screen.l;
     387    *r = screen.r;
     388}
     389
     390/*!
     391 * \brief set graphical clipping window to map window
     392 *
     393 * Sets the graphical clipping window to the pixel window that corresponds
     394 * to the current database region.
     395 *
     396 *  \param ~
     397 *  \return ~
     398 */
     399
     400void D_set_clip_window_to_map_window(void)
     401{
     402    D_set_clip_window(
     403        D_get_d_north(), D_get_d_south(),
     404        D_get_d_west(), D_get_d_east());
     405}
     406
     407/*!
     408 * \brief set clipping window to screen window
     409 *
     410 * Sets the clipping window to the pixel window that corresponds to the
     411 * full screen window. Off screen rendering is still clipped.
     412 *
     413 *  \param ~
     414 *  \return ~
     415 */
     416
     417void D_set_clip_window_to_screen_window(void)
     418{
     419    COM_Set_window(screen.t, screen.b, screen.l, screen.r);
     420}
     421
  • grass/trunk/lib/display/setup.c

    r52601 r62026  
    4747    double dt, db, dl, dr;
    4848
    49     D_get_window(&dt, &db, &dl, &dr);
     49    D_get_frame(&dt, &db, &dl, &dr);
    5050
    5151    G_get_set_window(&region);
     
    5454    D_do_conversions(&region, dt, db, dl, dr);
    5555
     56    D_set_clip_window_to_screen_window();
     57
    5658    if (clear)
    5759        D_erase(DEFAULT_BG_COLOR);
     60
     61    D_set_clip_window_to_map_window();
    5862}
    5963
     
    7478    double dt, db, dl, dr;
    7579
    76     D_get_window(&dt, &db, &dl, &dr);
     80    D_get_frame(&dt, &db, &dl, &dr);
    7781
    7882    D_set_src(dt, db, dl, dr);
     
    8185    D_update_conversions();
    8286
     87    D_set_clip_window_to_screen_window();
     88
    8389    if (clear)
    8490        D_erase(DEFAULT_BG_COLOR);
     91
     92    D_set_clip_window_to_map_window();
    8593}
    8694
     
    106114    double dt, db, dl, dr;
    107115
    108     D_get_window(&dt, &db, &dl, &dr);
     116    D_get_frame(&dt, &db, &dl, &dr);
    109117
    110118    D_set_src(st, sb, sl, sr);
     
    116124    D_update_conversions();
    117125
     126    D_set_clip_window_to_screen_window();
     127
    118128    if (clear)
    119129        D_erase(DEFAULT_BG_COLOR);
     130
     131    D_set_clip_window_to_map_window();
    120132}
Note: See TracChangeset for help on using the changeset viewer.