DAS  3.1.6 - 18/09/2017
Functions | Variables
D_Zoom.c File Reference

Danbo Zoom tool. More...

#include <windows.h>
#include <stdio.h>
#include <math.h>
#include "mgui.h"
#include "bil.h"
#include "DAS_Spatram.h"
+ Include dependency graph for D_Zoom.c:

Go to the source code of this file.

Functions

void D_DoLens (MIMAGE lensmim, MOBJECT lensdraw, int lenswx, int lenswy, int lenspix, int sx, int sy)
 
void D_Lens (void)
 
void D_LensCloseCB (MOBJECT p, void *od, void *ad)
 
void D_LensResizeCB (MOBJECT obj, DRAWAREA_PREF *pref, void *ad)
 
void D_LensZoom (MOBJECT o, MVALUE o_data, void *a_data)
 
void D_To_DoLens (void)
 

Variables

MOBJECT LensShell
 
unsigned int Maxx
 

Detailed Description

Danbo Zoom tool.

Author
Daniele Bortoli (16/11/2003)

Definition in file D_Zoom.c.

Function Documentation

§ D_DoLens()

void D_DoLens ( MIMAGE  lensmim,
MOBJECT  lensdraw,
int  lenswx,
int  lenswy,
int  lenspix,
int  sx,
int  sy 
)

Definition at line 29 of file D_Zoom.c.

References BIL, bil::BLENS, mtcl::blue, bil::DPLOT, d_view::Imax, blens::Imim, d_view::Imin, maxploth, MDrawBox(), MDrawImage(), MDrawLine(), MImageGetPixelRGB(), MImageSetPixelRGB(), MInstallImage(), MTCL, MUninstallImage(), and p.

Referenced by D_LensResizeCB(), D_LensZoom(), D_To_DoLens(), and DB_AreaInput().

30 {
31 
32  int l, h, p, d, md, x, y, wx, wy, ox, oy, px, py;
33  double dd;
34  int dred, dgreen, dblu;
35  sx++; sy++;
36  wx = lenswx / lenspix;
37  wy = lenswy / lenspix;
38  h= BIL.DPLOT.Imax;
39  l= BIL.DPLOT.Imin;
40 
41  p = lenspix;
42  d = h - l;
43  dd = d /= 256;
44  // If less then 256 levels
45  // inc range
46  if(d == 0)
47  {
48  md = 1;
49  dd = (double) (h - l) / 256.0;
50  if(dd == 0)
51  {
52  md = 0;
53  dd = d = 1;
54  }
55  }
56  for(y = sy - wy / 2; y < sy + wy / 2; y++)
57  {
58 
59 
60 // ma = &DPLOT.Graf[(long) y * maxplotw];
61 
62  for(x = sx - wx / 2; x < sx + wx / 2; x++)
63  {
64  if(x >= 0 && x < maxplotw && y >= 0 && y < maxploth)
65  {
66  MImageGetPixelRGB(BIL.BLENS.Imim, x, y, &dred, &dgreen, &dblu);
67  }
68  ox = (long) (x - (sx - wx / 2)) * p;
69  oy = (long) (y - (sy - wy / 2)) * p;
70  for(py = 0; py < p; py++)
71  for(px = 0; px < p; px++)
72  MImageSetPixelRGB(lensmim, ox + px, oy + py, dred, dgreen, dblu);
73  }
74  }
75 
76  MInstallImage(lensmim);
77  MDrawImage(lensdraw, lensmim, 0, 0, wx * p, wy * p, 0, 0);
78  MUninstallImage(lensmim);
79 
80  sx = wx / 2 * p - p;
81  sy = wy / 2 * p - p;
82  MDrawBox(lensdraw, wx / 2 * p - p, wy / 2 * p - p, p, p, MTCL.blue);
83 
84  // Y line
85  MDrawLine(lensdraw, sx + p / 2, sy - 30, sx + p / 2, sy, MTCL.blue);
86  MDrawLine(lensdraw, sx + p / 2, sy + p, sx + p / 2, sy + 30 + p, MTCL.blue);
87 
88  // X Line
89  MDrawLine(lensdraw, sx - 30, sy + p / 2, sx, sy + p / 2, MTCL.blue);
90  MDrawLine(lensdraw, sx + p + 30, sy + p / 2, sx + p, sy + p / 2, MTCL.blue);
91 
92 }
mtcl MTCL
Definition: 2DPlot.c:30
MIMAGE Imim
Definition: bildef.h:14
MTColor blue
void MDrawLine(MOBJECT p, int x1, int y1, int x2, int y2, MTColor col)
unsigned int Imax
Definition: bildef.h:177
unsigned int Imin
Definition: bildef.h:178
d_view DPLOT
Definition: bildef.h:254
void MImageSetPixelRGB(MIMAGE pmi, int x, int y, int r, int g, int b)
void MDrawBox(MOBJECT p, int x, int y, int w, int h, MTColor bgc)
int maxploth
Definition: Spat_Plot.c:51
void MInstallImage(MIMAGE data)
bil BIL
Definition: 2DPlot.c:28
static double p
Definition: SOLPOS.C:131
void MDrawImage(MOBJECT p, MIMAGE gi, int pm_x, int pm_y, int w, int h, int x, int y)
blens BLENS
Definition: bildef.h:252
void MUninstallImage(MIMAGE data)
void MImageGetPixelRGB(MIMAGE pmi, int x, int y, int *pr, int *pg, int *pb)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ D_Lens()

void D_Lens ( void  )

Definition at line 138 of file D_Zoom.c.

References BIL, bil::BLENS, D_LensCloseCB(), D_LensResizeCB(), D_LensZoom(), D_To_DoLens(), False, HELV_SMALL, lbl, blens::LensDraw, blens::LensLbl, blens::LensLblX, blens::LensLblY, blens::LensMim, blens::LensON, blens::LensPix, LensShell, blens::LensWx, blens::LensWy, MAllocImage(), Maxx, MAXZOOM, MCreateColForm(), MCreateDrawArea(), MCreateLabel(), MCreateRowForm(), MCreateScrollBar(), MCreateShell(), MDrawAreaSetExposeCallback(), MDrawAreaSetResizeCallback(), MGetScreenWidth(), MObjectSetBackgroundRGB(), MObjectSetResize(), MObjectSetShadow(), MScrollBarSetPos(), MScrollBarSetPosCallback(), MShellRaise(), MShellRealize(), MShellSetWMCloseCallback(), newfont, SBT_HOR, SF_NO_MAXIMIZE, SF_NO_MINIMIZE, True, and WS_NONE.

Referenced by D_PButt_CB(), and MenuToolsOLP_CB().

139 {
140  MOBJECT a, b, lbl, sb;
141  MTFont newfont;
142 
143  newfont = HELV_SMALL; //MLoadFont("Times", 16, False, False);
144 
145  if(BIL.BLENS.LensON)
146  {
148  return;
149  }
150 
152  MObjectSetBackgroundRGB(LensShell, 64, 68, 72);
153 
155  MObjectSetShadow(a, WS_NONE, 0, 0);
156  MObjectSetBackgroundRGB(a, 128, 128, 128);
157 
158  Maxx = MGetScreenWidth();
159  BIL.BLENS.LensWx = Maxx / 4;
160 
161  BIL.BLENS.LensPix = 2;
162 
164 
167 
171 
172  b = MCreateColForm(a);
173  MObjectSetBackgroundRGB(b, 184, 132, 0);
174 
175  lbl = MCreateLabel(b, "X:", newfont);
176  MObjectSetBackgroundRGB(lbl, 255,255,255);
177  MObjectSetResize(lbl, False, True);
178 // MObjectSetForegroundRGB(lbl, );
179 
180  BIL.BLENS.LensLblX = MCreateLabel(b, " 0000 ", newfont);
183 // MObjectSetForegroundRGB(LensLblX, );
184 
185  lbl = MCreateLabel(b, "Y:", newfont);
186  MObjectSetBackgroundRGB(lbl, 255,255,255);
187 // MObjectSetForegroundRGB(lbl, );
188  BIL.BLENS.LensLblY = MCreateLabel(b, "0000", newfont);
190 // MObjectSetForegroundRGB(LensLblY, );
191 
192  BIL.BLENS.LensLbl = MCreateLabel(b, "ZOOM = 2", newfont);
195 
196 
197  b = MCreateColForm(a);
198 // MObjectSetBackgroundRGB(b, );
199 
200  sb = MCreateScrollBar(a, SBT_HOR, 0, MAXZOOM);
201  MScrollBarSetPos(sb, 0);
202  MScrollBarSetPosCallback(sb, D_LensZoom, (void *) 0);
203  MObjectSetBackgroundRGB(sb, 184, 132, 0);
204 // MObjectSetForegroundRGB(sb, );
205 
208  BIL.BLENS.LensON = 1;
209 }
MTFont newfont
Definition: CreateForms.c:95
void MObjectSetBackgroundRGB(MOBJECT obj, int r, int g, int b)
#define WS_NONE
Definition: Mguidefs.h:956
unsigned int Maxx
Definition: D_Zoom.c:18
MOBJECT lbl
Definition: DFileMan.c:42
MIMAGE LensMim
Definition: bildef.h:12
void MObjectSetShadow(MOBJECT obj, int type, int in, int out)
void MShellRealize(MOBJECT obj)
#define SF_NO_MAXIMIZE
Definition: Mguidefs.h:1034
MOBJECT LensLblY
Definition: bildef.h:11
int LensPix
Definition: bildef.h:9
MOBJECT MCreateLabel(MOBJECT parent, const char *text, MTFont font)
void MObjectSetResize(MOBJECT obj, int resize_w, int resize_h)
#define False
Definition: Mguidefs.h:236
void D_LensZoom(MOBJECT o, MVALUE o_data, void *a_data)
Definition: D_Zoom.c:94
#define SF_NO_MINIMIZE
Definition: Mguidefs.h:1036
void MDrawAreaSetResizeCallback(MOBJECT obj, DRAWAREA_PREF_CB cb, void *ad)
MOBJECT LensShell
Definition: D_Zoom.c:16
void D_LensResizeCB(MOBJECT obj, DRAWAREA_PREF *pref, void *ad)
Definition: D_Zoom.c:115
void D_LensCloseCB(MOBJECT p, void *od, void *ad)
Definition: D_Zoom.c:129
#define HELV_SMALL
Definition: Mguidefs.h:881
unsigned char LensON
Definition: bildef.h:8
MOBJECT MCreateScrollBar(MOBJECT parent, int type, long n, long max)
int MTFont
Definition: Mguidefs.h:175
void MScrollBarSetPos(MOBJECT p, long pos)
#define SBT_HOR
Definition: Mguidefs.h:1139
void(* OBJ_EVENT_CB)(MOBJECT obj, MEvent *e, void *ad)
Definition: Mguidefs.h:1456
MOBJECT MCreateDrawArea(MOBJECT parent, int width, int height)
MOBJECT MCreateColForm(MOBJECT parent)
void MDrawAreaSetExposeCallback(MOBJECT obj, OBJ_EVENT_CB cb, void *ad)
MOBJECT MCreateShell(const char *title, int flags)
void D_To_DoLens(void)
Definition: D_Zoom.c:111
void MShellRaise(MOBJECT obj)
bil BIL
Definition: 2DPlot.c:28
int MGetScreenWidth(void)
void * MOBJECT
Definition: Mguidefs.h:192
blens BLENS
Definition: bildef.h:252
#define True
Definition: Mguidefs.h:235
MOBJECT LensDraw
Definition: bildef.h:11
MIMAGE MAllocImage(int img_w, int img_h, int nplanes)
int LensWx
Definition: bildef.h:10
MOBJECT LensLblX
Definition: bildef.h:11
void MShellSetWMCloseCallback(MOBJECT p, WM_CLOSE_CB cb, void *a_data)
MOBJECT MCreateRowForm(MOBJECT parent)
#define MAXZOOM
Definition: bildef.h:20
int LensWy
Definition: bildef.h:10
void MScrollBarSetPosCallback(MOBJECT p, OBJ_VALUE_CB cb, void *data)
MOBJECT LensLbl
Definition: bildef.h:11
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ D_LensCloseCB()

void D_LensCloseCB ( MOBJECT  p,
void *  od,
void *  ad 
)

Definition at line 129 of file D_Zoom.c.

References BIL, bil::BLENS, blens::LensMim, blens::LensON, MFreeImage(), MShellDestroy(), and MShellUnrealize().

Referenced by D_Lens().

130 {
132  MShellDestroy(p);
133  BIL.BLENS.LensON = 0;
135 
136 }
MIMAGE LensMim
Definition: bildef.h:12
void MShellUnrealize(MOBJECT obj)
void MShellDestroy(MOBJECT obj)
unsigned char LensON
Definition: bildef.h:8
void MFreeImage(MIMAGE data)
bil BIL
Definition: 2DPlot.c:28
static double p
Definition: SOLPOS.C:131
blens BLENS
Definition: bildef.h:252
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ D_LensResizeCB()

void D_LensResizeCB ( MOBJECT  obj,
DRAWAREA_PREF pref,
void *  ad 
)

Definition at line 115 of file D_Zoom.c.

References BIL, bil::BLENS, D_DoLens(), blens::LensDraw, blens::LensMim, blens::LensPix, blens::LensWx, blens::LensWy, blens::LocX, blens::LocY, blens::LWx, blens::LWy, MAllocImage(), MFreeImage(), DRAWAREA_PREF::new_h, and DRAWAREA_PREF::new_w.

Referenced by D_Lens().

116 {
117 
118  BIL.BLENS.LensWx = pref->new_w;
119  BIL.BLENS.LensWy = pref->new_h;
120 
123 
127 
128 }
unsigned int LocX
Definition: bildef.h:15
MIMAGE LensMim
Definition: bildef.h:12
int LensPix
Definition: bildef.h:9
void D_DoLens(MIMAGE lensmim, MOBJECT lensdraw, int lenswx, int lenswy, int lenspix, int sx, int sy)
Definition: D_Zoom.c:29
void MFreeImage(MIMAGE data)
bil BIL
Definition: 2DPlot.c:28
unsigned int LocY
Definition: bildef.h:15
int LWy
Definition: bildef.h:10
blens BLENS
Definition: bildef.h:252
MOBJECT LensDraw
Definition: bildef.h:11
int LWx
Definition: bildef.h:10
MIMAGE MAllocImage(int img_w, int img_h, int nplanes)
int LensWx
Definition: bildef.h:10
int LensWy
Definition: bildef.h:10
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ D_LensZoom()

void D_LensZoom ( MOBJECT  o,
MVALUE  o_data,
void *  a_data 
)

Definition at line 94 of file D_Zoom.c.

References BIL, bil::BLENS, D_DoLens(), blens::LensDraw, blens::LensMim, blens::LensPix, blens::LensWx, blens::LensWy, blens::LocX, blens::LocY, blens::LWx, and blens::LWy.

Referenced by D_Lens().

95 {
96  int l = (int) o_data, w = (int) a_data;
97  char buf[16];
98 
99  if(l < 2) l = 2;
100  BIL.BLENS.LensPix = l;
101  sprintf(buf, "DanBo ZOOM = %d", BIL.BLENS.LensPix);
102 
105 
106  //MObjectSetText(LensLbl, buf);
107 // MShellSetTitle(BIL.BLENS.LensShell, buf);
109 
110 }
unsigned int LocX
Definition: bildef.h:15
MIMAGE LensMim
Definition: bildef.h:12
int LensPix
Definition: bildef.h:9
void D_DoLens(MIMAGE lensmim, MOBJECT lensdraw, int lenswx, int lenswy, int lenspix, int sx, int sy)
Definition: D_Zoom.c:29
bil BIL
Definition: 2DPlot.c:28
unsigned int LocY
Definition: bildef.h:15
int LWy
Definition: bildef.h:10
blens BLENS
Definition: bildef.h:252
MOBJECT LensDraw
Definition: bildef.h:11
int LWx
Definition: bildef.h:10
int LensWx
Definition: bildef.h:10
int LensWy
Definition: bildef.h:10
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ D_To_DoLens()

void D_To_DoLens ( void  )

Definition at line 111 of file D_Zoom.c.

References BIL, bil::BLENS, D_DoLens(), blens::LensDraw, blens::LensMim, blens::LensPix, blens::LocX, blens::LocY, blens::LWx, and blens::LWy.

Referenced by D_Lens().

112 {
114 }
unsigned int LocX
Definition: bildef.h:15
MIMAGE LensMim
Definition: bildef.h:12
int LensPix
Definition: bildef.h:9
void D_DoLens(MIMAGE lensmim, MOBJECT lensdraw, int lenswx, int lenswy, int lenspix, int sx, int sy)
Definition: D_Zoom.c:29
bil BIL
Definition: 2DPlot.c:28
unsigned int LocY
Definition: bildef.h:15
int LWy
Definition: bildef.h:10
blens BLENS
Definition: bildef.h:252
MOBJECT LensDraw
Definition: bildef.h:11
int LWx
Definition: bildef.h:10
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

§ LensShell

MOBJECT LensShell

Definition at line 16 of file D_Zoom.c.

Referenced by D_Lens().

§ Maxx

unsigned int Maxx

Definition at line 18 of file D_Zoom.c.

Referenced by D_Lens().

______________________________________________________________________________________
Generated on Mon Sep 18 2017 11:44:28 for DAS - Rel. 3.1.6 - 18/09/2017.