Changeset 42940
- Timestamp:
- Nov 12, 2025, 4:59:11 PM (8 months ago)
- Location:
- trunk/Ohana/src/kapa2
- Files:
-
- 5 edited
-
include/prototypes.h (modified) (1 diff)
-
src/CheckPipe.c (modified) (1 diff)
-
src/DefineSection.c (modified) (6 diffs)
-
src/SetGraphSize.c (modified) (1 diff)
-
src/bDrawImage.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/kapa2/include/prototypes.h
r42821 r42940 80 80 int DefineSection PROTO((int sock)); 81 81 int DefineSectionByImage PROTO((int sock)); 82 int DefineSectionCenterByImage PROTO((int sock)); 82 83 int SetFont PROTO((int sock)); 83 84 int EraseCurrentPlot PROTO((void)); -
trunk/Ohana/src/kapa2/src/CheckPipe.c
r41341 r42940 245 245 } 246 246 247 if (!strcmp (word, "CSEC")) { 248 status = DefineSectionCenterByImage (sock); 249 KiiSendCommand (sock, 4, "DONE"); 250 FINISHED (TRUE); 251 } 252 247 253 if (!strcmp (word, "MSEC")) { 248 254 status = MoveSection (sock); -
trunk/Ohana/src/kapa2/src/DefineSection.c
r29938 r42940 9 9 Section *section; 10 10 11 // XXX the background must be set using KapaSectionBG 11 12 KiiScanMessage (sock, "%s %lf %lf %lf %lf %d", name, &x, &y, &dx, &dy, &bg); 13 14 // truncate section to 0.0 - 1.0 15 x = MAX(MIN(x,1.0),0.0); 16 y = MAX(MIN(y,1.0),0.0); 17 18 double xmax = MAX(MIN(x + dx, 1.0), 0.0); 19 double ymax = MAX(MIN(y + dy, 1.0), 0.0); 20 dx = xmax - x; 21 dy = ymax - y; 12 22 13 23 MoveSection = FALSE; … … 15 25 N = GetSectionByName (name); 16 26 if (N < 0) { 17 section = AddSection (name, x, y, dx, dy, bg); 27 // new section is added with transparent background 28 section = AddSection (name, x, y, dx, dy, -1); 18 29 MoveSection = TRUE; 19 30 } else { … … 30 41 section[0].dx = dx; 31 42 section[0].dy = dy; 32 section[0].bg = bg; 43 // do not change bg (must use KapaSectionBG) 44 // section[0].bg = bg; 33 45 } 34 46 … … 56 68 57 69 N = GetSectionByName (name); 70 if (N < 0) { 71 fprintf (stderr, "section does not yet exist\n"); 72 return (TRUE); 73 } 58 74 section = GetSectionByNumber (N); 59 75 image = section->image; … … 82 98 section[0].x = x; 83 99 section[0].y = y; 84 section[0].bg = bg;100 // section[0].bg = bg; 85 101 section[0].dx = dx / graphic[0].dx; 86 102 section[0].dy = dy / graphic[0].dy; … … 96 112 return (TRUE); 97 113 } 114 115 // define the section, but do not create a graph or image 116 int DefineSectionCenterByImage (int sock) { 117 118 int N; 119 char name[128]; 120 double x, y, dx, dy; 121 int dXm, dXp, dYm, dYp; 122 double x0, y0, x1, y1, expand; 123 Section *section; 124 Graphic *graphic; 125 KapaImageWidget *image; 126 127 // x,y is the center of the image, adjust section to contain the image 128 KiiScanMessage (sock, "%s %lf %lf", name, &x, &y); 129 130 N = GetSectionByName (name); 131 if (N < 0) { 132 fprintf (stderr, "section does not yet exist\n"); 133 return (TRUE); 134 } 135 section = GetSectionByNumber (N); 136 image = section->image; 137 if (!image) { 138 fprintf (stderr, "no image to define section\n"); 139 return (TRUE); 140 } 141 SetActiveSectionByNumber (N); 142 143 graphic = GetGraphic (); 144 145 GetGraphBoundary (section, &x0, &y0, &x1, &y1, &dXm, &dXp, &dYm, &dYp); 146 147 expand = 1.0; 148 if (image[0].picture.expand > 0) { 149 expand = image[0].picture.expand; 150 } 151 if (image[0].picture.expand < 0) { 152 expand = 1.0 / fabs((double)image[0].picture.expand); 153 } 154 155 // pixel dimensions of the imaging region + boundary 156 dx = MIN (image[0].image[0].matrix.Naxis[0]*expand + x1, graphic[0].dx); 157 dy = MIN (image[0].image[0].matrix.Naxis[1]*expand + y1, graphic[0].dy); 158 159 // dx,dy cannot be larger than 1.0 160 161 // section[0].bg = bg; 162 section[0].dx = dx / graphic[0].dx; 163 section[0].dy = dy / graphic[0].dy; 164 165 // translate the section center (x,y) to the section corner 166 167 // desired center of section in pixels 168 double Xc_pix = x*graphic->dx; 169 double Yc_pix = y*graphic->dy; 170 171 // this is the size if the full image fits, saturate on graphic boundary 172 double Xs_pix = MAX(MIN(Xc_pix - 0.5*dx, graphic->dx), 0.0); 173 double Xe_pix = MAX(MIN(Xc_pix + 0.5*dx, graphic->dx), 0.0); 174 175 section[0].x = Xs_pix / graphic->dx; 176 section[0].dx = (Xe_pix - Xs_pix) / graphic->dx; 177 178 double Ys_pix = MAX(MIN(Yc_pix - 0.5*dy, graphic->dy), 0.0); 179 double Ye_pix = MAX(MIN(Yc_pix + 0.5*dy, graphic->dy), 0.0); 180 181 section[0].y = Ys_pix / graphic->dy; 182 section[0].dy = (Ye_pix - Ys_pix) / graphic->dy; 183 184 // if (section[0].x != x) MoveSection = TRUE; 185 // if (section[0].y != y) MoveSection = TRUE; 186 // if (section[0].dx != dx) MoveSection = TRUE; 187 // if (section[0].dy != dy) MoveSection = TRUE; 188 189 SetSectionSizes (section); 190 Refresh (); 191 192 return (TRUE); 193 } -
trunk/Ohana/src/kapa2/src/SetGraphSize.c
r41344 r42940 19 19 graphic = GetGraphic (); 20 20 21 // graphic->dx,dy : size of the full window 22 // (x0,y0) : distance of (LL) corner of box relative to section corner 23 // (x1,y1) : distance of (UR) corner of box relative to section corner 21 24 double X0 = graphic[0].dx * section[0].x + x0; 22 25 double Y0 = graphic[0].dy * section[0].y + y0; -
trunk/Ohana/src/kapa2/src/bDrawImage.c
r41341 r42940 59 59 if (Xs < 0) { 60 60 fprintf (stderr, "image display boundaries out of range of window (invalid condition) : fix Kapa\n"); 61 fprintf (stderr, "Xs,Ys: %d,%d\n", Xs, Ys); 62 fprintf (stderr, "dx,dy: %d,%d\n", dx, dy); 63 fprintf (stderr, "picture.x,y: %d,%d\n", image[0].picture.x, image[0].picture.y); 64 fprintf (stderr, "picture.dx,dy: %d,%d\n", image[0].picture.dx, image[0].picture.dy); 61 65 abort(); 62 66 } 63 67 if (buffer[0].Nx < Xs + dx) { 64 68 fprintf (stderr, "image display boundaries out of range of window (invalid condition) : fix Kapa\n"); 69 fprintf (stderr, "Xs,Ys: %d,%d\n", Xs, Ys); 70 fprintf (stderr, "dx,dy: %d,%d\n", dx, dy); 71 fprintf (stderr, "picture.x,y: %d,%d\n", image[0].picture.x, image[0].picture.y); 72 fprintf (stderr, "picture.dx,dy: %d,%d\n", image[0].picture.dx, image[0].picture.dy); 65 73 abort(); 66 74 } 67 75 if (Ys < 0) { 68 76 fprintf (stderr, "image display boundaries out of range of window (invalid condition) : fix Kapa\n"); 77 fprintf (stderr, "Xs,Ys: %d,%d\n", Xs, Ys); 78 fprintf (stderr, "dx,dy: %d,%d\n", dx, dy); 79 fprintf (stderr, "picture.x,y: %d,%d\n", image[0].picture.x, image[0].picture.y); 80 fprintf (stderr, "picture.dx,dy: %d,%d\n", image[0].picture.dx, image[0].picture.dy); 69 81 abort(); 70 82 } 71 83 if (buffer[0].Ny < Ys + dy) { 72 84 fprintf (stderr, "image display boundaries out of range of window (invalid condition) : fix Kapa\n"); 85 fprintf (stderr, "Xs,Ys: %d,%d\n", Xs, Ys); 86 fprintf (stderr, "dx,dy: %d,%d\n", dx, dy); 87 fprintf (stderr, "picture.x,y: %d,%d\n", image[0].picture.x, image[0].picture.y); 88 fprintf (stderr, "picture.dx,dy: %d,%d\n", image[0].picture.dx, image[0].picture.dy); 73 89 abort(); 74 90 }
Note:
See TracChangeset
for help on using the changeset viewer.
