IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 27, 2019, 11:00:17 AM (7 years ago)
Author:
eugene
Message:

add memory cleanup functions; add buffered drawing to allow opacity in X; add reversed colormaps; add multi-point polygon plots (and filled versions); add memory checks; add buffer smoothing for anti-aliasing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/kapa2/src/Refresh.c

    r36833 r41157  
    11# include "Ximage.h"
    22
     3# define USE_BUFFERED_DRAW 1
     4
     5void bDrawXimage (bDrawBuffer *buffer);
     6void Refresh_Buffered (void);
     7void Refresh_Unbuffered (void);
     8
    39void Refresh (void) {
     10  if (USE_BUFFERED_DRAW) {
     11    Refresh_Buffered();
     12  } else {
     13    Refresh_Unbuffered();
     14  }
     15}
     16
     17void Refresh_Buffered (void) {
     18
     19  int Npalette;
     20  Graphic *graphic;
     21
     22  if (!USE_XWINDOW) return;
     23  // if (HAVE_BACKING) return;
     24
     25  graphic = GetGraphic();
     26 
     27  // limit the png window to the min needed to contain the active graphic regions
     28  SectionMinBoundary (graphic);
     29
     30  // is the palette reasonable in modern context?
     31  png_color *palette = KapaPNGPalette (&Npalette);
     32
     33  bDrawBuffer *buffer = bDrawIt (palette, Npalette, 3);
     34 
     35  /* XClearWindow   (graphic.display, graphic.window); */
     36  XSetForeground (graphic->display, graphic->gc, graphic->back);
     37  XFillRectangle (graphic->display, graphic->window, graphic->gc, 0, 0, graphic->dx, graphic->dy);
     38  XSetForeground (graphic->display, graphic->gc, graphic->fore);
     39 
     40  // copy buffer to Xwindow as image?
     41  bDrawXimage (buffer);
     42  bDrawBufferFree (buffer);
     43  free (palette);
     44
     45  // draw image tool for all sections
     46  int Nsection = GetNumberOfSections ();
     47  for (int i = 0; i < Nsection; i++) {
     48    Section *section = GetSectionByNumber (i);
     49
     50    KapaImageWidget *image = section->image;
     51    DrawImageTool (image);
     52
     53    /*** PaintOverlay is called in DrawImage ***
     54    if (!image) continue;
     55    for (int j = 0; j < NOVERLAYS; j++) {
     56      if (image[0].overlay[j].active) {
     57        PaintOverlay (graphic, image, j);
     58      }
     59    }
     60    */
     61  }
     62
     63  FlushDisplay ();
     64}
     65
     66void Refresh_Unbuffered (void) {
    467
    568  int i, Nsection;
     
    2083  Nsection = GetNumberOfSections ();
    2184  for (i = 0; i < Nsection; i++) {
    22       section = GetSectionByNumber (i);
    23       DrawSectionBG (graphic, section);
    24       DrawImage (section->image);
    25       DrawGraph (section->graph);
     85    section = GetSectionByNumber (i);
     86    DrawSectionBG (graphic, section);
     87
     88    KapaImageWidget *image = section->image;
     89    DrawImage (image);
     90    DrawImageTool (image);
     91
     92    /*** the overlay is added in DrawImage  ***/
     93    if (image) {
     94      for (int j = 0; j < NOVERLAYS; j++) {
     95        if (image[0].overlay[j].active) {
     96          PaintOverlay (graphic, image, j);
     97        }
     98      }
     99    }
     100
     101    DrawGraph (section->graph);
    26102  }
    27103
Note: See TracChangeset for help on using the changeset viewer.