Fisheries and Oceans Canada / Pêches et Océans Canada - Government of Canada / Gouvernement du Canada Fisheries and Oceans Canada / Pêches et Océans Canada - Government of Canada / Gouvernement du Canada
 
Français Contact Us Help Search Canada Site
Home What's New DFO National Site Map Media

Fisheries & Oceans
 
 
Maritimes Region
Fishing Industry
General Public
Marine & Oceans Industry
Media
Students and Teachers
Scientists and Researchers
 
AconIconACON       Home/Topics   |   Commands   |   More Examples

User-defined Data Dialog


User Defined Data Dialog

/*----------------------------------------------*/
/* DrawPlot - Draw the data and highlight selection */
/*----------------------------------------------*/
Function DrawPlot(w,left,right,bot,top)
{
Data_Viewport(left+mm(10), right-mm(10), bot+mm(10), top-mm(10));
Axis(2.,2.,0.,0.,1,0,1,0,0);
Overlay_File(mappath("COAST1"));
Data_Line(lon,lat);
if (len(dragrect)[1] > 0)
{ /* draw the mouse selection rectangle*/
Line_Type(1); draw(dragrect); Line_Type(0);
};
if (sum(found) > 0)
{/* draw selected point(s) */
Marker_Height(mm(2));
Data_Points(select(found, lon), select(found, lat));
Marker_Height(mm(1));
};
};

/*----------------------------------------------*/
/* MouseDown - save starting click point */
/*----------------------------------------------*/
Function MouseDown(w, left, right, bot, top, mx, my)
{
Data_Viewport(left+mm(10), right-mm(10), bot+mm(10), top-mm(10));
sndc = cat(0,mx,my); endc = sndc;
dragrect = shape(0 2,0.0);
return(0);
};

/*----------------------------------------------*/
/* MouseStillDown - find data with drag rect */
/*----------------------------------------------*/
Function MouseStillDown(w, left, right, bot, top, mx, my)
{
endc = cat(0,mx,my);
x1 = min(sndc[1],endc[1]);
x2 = max(sndc[1],endc[1]);
y1 = min(sndc[2],endc[2]);
y2 = max(sndc[2],endc[2]);
dragrect = shape(5 2, cat(0, x1, y1, x1, y2, x2, y2, x2, y1, x1, y1));
Data_Viewport(left+mm(10), right-mm(10), bot+mm(10), top-mm(10));
pndc = user(lon,lat); /* convert original data to NDCs */
Echo(0);
found = inside(dragrect,pndc);
Echo(1);
};

/*----------------------------------------------*/
/* MouseUp - select single click points */
/*----------------------------------------------*/
Function MouseUp(w,left,right,bot,top,mx,my)
{
if ((sndc[1] == endc[1]) && (sndc[2] == endc[2]))
{
Data_Viewport(left+mm(10), right-mm(10), bot+mm(10), top-mm(10));
pndc = user(lon,lat); /* convert original data to NDCs */
deltax = (mx - pndc[;1]);
deltay = (my - pndc[;2]);
dist = sqrt(deltax*deltax + deltay*deltay);
found = dist <= pts(500);
};
};

Data_Window(-66,-50,40,45);
Data_Projection("Mercator");
lon = -64 -60 -55 -52 -57 -63.;
lat = 41 41 42 43 44 42.;
found = shape(len(lon),0);
dragrect = shape(0 2,0.0);
Data_Dialog(4, "DrawPlot", $Null, "MouseDown", "MouseStillDown", "MouseUp");

AconIconACON       Home/Topics   |   Commands   |   More Examples



Last Modified : 2003-11-19