Laxkit
0.0.7.1
|
A graphics drawing wrapper. More...
Public Member Functions | |
Displayer (aDrawable *d) | |
Displayer (anXWindow *w=NULL, PanController *pan=NULL) | |
Constructor, set everything to nothing or identity. | |
virtual | ~Displayer () |
Destructor. | |
virtual Displayer * | duplicate ()=0 |
Window specific helper functions: | |
virtual aDrawable * | GetDrawable () |
Buffer Management | |
virtual void | SwapBuffers ()=0 |
virtual void | BackBuffer (int on)=0 |
virtual void | WrapWindow (anXWindow *nw) |
Set the viewable portion of the displayer to correspond with the window's win_w and win_h. | |
virtual int | StartDrawing (aDrawable *buffer)=0 |
Set up to be drawing on a buffer. | |
virtual int | MakeCurrent (aDrawable *buffer)=0 |
Update the drawing context so that all drawing operations will now operate on buffer. | |
virtual int | ClearDrawable (aDrawable *drawable)=0 |
Free any data associated with drawable. Return 1 for drawable not currently used, or 0 for cleared. | |
virtual int | CreateSurface (int width, int height, int type=-1)=0 |
Clear the old surface, and create a fresh surface to perform drawing operations on. | |
virtual LaxImage * | GetSurface ()=0 |
Return a new LaxImage that is copied from the current buffer. | |
virtual int | ResizeSurface (int width, int height)=0 |
Resize an internal drawing surface. | |
virtual int | EndDrawing ()=0 |
Set everything assuming we do not need to draw on the current surface for the time being. | |
State | |
virtual unsigned long | NewFG (double r, double g, double b, double a=1.0)=0 |
Set new foreground color. Typically usage is NewFG(app->rgbcolor(.5,.8,0,1.0)). Component range is [0..1.0]. | |
virtual unsigned long | NewFG (unsigned long ncol)=0 |
Set new foreground. Typically usage is NewFG(app->rgbcolor(23,34,234)). | |
virtual unsigned long | NewFG (ScreenColor *col)=0 |
Set new foreground. Color components are 0..0xffff. | |
virtual unsigned long | NewFG (int r, int g, int b, int a=255)=0 |
Set new foreground. Typically usage is NewFG(app->rgbcolor(23,34,234)). Component range is currently 0..255.... subject to change. | |
virtual unsigned long | NewBG (double r, double g, double b)=0 |
Set new background color. Typically usage is NewFG(app->rgbcolor(.5,.8,0)). Component range is [0..1.0]. | |
virtual unsigned long | NewBG (int r, int g, int b)=0 |
Set new background. Typically usage is NewBG(app->rgbcolor(23,34,234)). | |
virtual unsigned long | NewBG (unsigned long nc)=0 |
Set new background. Typically usage is NewBG(app->rgbcolor(23,34,234)). | |
virtual unsigned long | FG ()=0 |
virtual unsigned long | BG ()=0 |
virtual void | LineAttributes (double width, int dash, int cap, int join)=0 |
Set the width, whether solid, line cap and join. | |
virtual void | FillAttributes (int fillstyle, int fillrule)=0 |
virtual LaxCompositeOp | BlendMode (LaxCompositeOp mode)=0 |
Set how to combine drawing elements to the target surface, return the old one. | |
Main drawing functions: | |
virtual void | ClearWindow ()=0 |
Clear the window to bgcolor between Min* and Max*. | |
virtual flatpoint | realtoscreen (flatpoint p)=0 |
Convert real point p to screen coordinates. | |
virtual flatpoint | realtoscreen (double x, double y)=0 |
Convert real point (x,y) to screen coordinates. | |
virtual flatpoint | screentoreal (int x, int y)=0 |
Convert screen point (x,y) to real coordinates. | |
virtual flatpoint | screentoreal (flatpoint p)=0 |
Convert screen point p to real coordinates. | |
virtual int | Clip (flatpoint *p, int n, int append)=0 |
Set the clipping area to the path defined by the given polyline. | |
virtual void | PushClip (int startfresh)=0 |
Push the current clip mask onto a stack, make a new one maybe. | |
virtual void | PopClip ()=0 |
Restore a previous clipping area. | |
virtual void | ClearClip ()=0 |
Clear any clip state. | |
virtual int | activeMask ()=0 |
Turn on or off the usage of double buffering. | |
virtual int | DrawReal () |
Any subsequent calls are using real coordinates. | |
virtual int | DrawScreen () |
Any subsequent calls are using screen coordinates. | |
virtual void | Radians () |
Interpret all angles as radians. | |
virtual void | Degrees () |
Interpret all angles as radians. | |
virtual void | DrawOnMask () |
Subclasses must redefine this is modifying the mask is ok. | |
virtual void | DrawOnSrc () |
Ensure that drawing operations work on source (as opposed to mask). | |
virtual int | DrawImmediately (int yes) |
Do not append path operations, draw them with each call. | |
virtual int | onscreen (double x, double y) |
Return whether the given (screen) point is in the viewable area or not. | |
virtual void | show ()=0 |
Flush waiting composite operation. | |
virtual void | fill (int preserve)=0 |
Fill any stored path(s). If preserve, then do not clear the path afterward. | |
virtual void | stroke (int preserve)=0 |
Paint any stored path(s). If preserve, then do not clear the path afterward. | |
virtual void | moveto (double x, double y) |
virtual void | moveto (flatpoint p)=0 |
Relocate path building to the point. | |
virtual void | lineto (double x, double y) |
virtual void | lineto (flatpoint p)=0 |
Add a segment to the current path. | |
virtual void | curveto (flatpoint c1, flatpoint c2, flatpoint v)=0 |
Add a bezier curve to the current path. | |
virtual void | closed ()=0 |
Call if current path should be closed, and close at the last added point. | |
virtual void | closeopen ()=0 |
Call if current path should be ended, but not closed. | |
virtual void | drawpixel (flatpoint p)=0 |
Draw one screen pixel at coord p. Transform to screen coordinates if real!=0. | |
virtual void | drawpoint (double x, double y, double radius, int fill)=0 |
Draw a little circle at real or screen coord (x,y) with screen radius r. | |
virtual void | drawpoint (flatpoint p, double radius, int fill) |
Draw a little circle at p with screen radius. | |
virtual void | drawlines (flatpoint *points, int npoints, char closed, char fill)=0 |
Draw a polygon, optionally closed, optionally fill, optionally transform. | |
virtual void | drawline (flatpoint p1, flatpoint p2)=0 |
Draw a line between real coordinates p1 and p2. | |
virtual void | drawline (double ax, double ay, double bx, double by) |
Draw a line between coordinates (ax,ay) and (bx,by). | |
virtual void | drawrectangle (double x, double y, double w, double h, int tofill) |
Draw a basic rectangle. | |
virtual void | drawbez (flatpoint *bpoints, int n, int isclosed=0, int tofill=0) |
Draw a cubic bezier line. | |
virtual int | drawrealline (flatline &ln, int num) |
Draw a line across the whole view, and if num!=-10000000, print the number num where the line hits the sides of the window. | |
virtual void | drawellipse (double x, double y, double xradius, double yradius, double start_angle=0, double end_angle=0, int fill=0) |
Draw an ellipse with center at real point p.. | |
virtual void | drawellipse (flatpoint p, double xradius, double yradius, double start_angle=0, double end_angle=0, int fill=0) |
Draw an ellipse in the rectangle spanned by p +/- (xradius,yradius). | |
virtual void | drawarc (flatpoint p, double xr, double yr, double start_angle=0, double end_angle=0) |
Draw part of an ellipse. | |
virtual void | drawfocusellipse (flatpoint focus1, flatpoint focus2, double c, double start_angle=0, double end_angle=0, int fill=0) |
Draw an ellipse based on the foci. | |
virtual void | drawthing (double x, double y, double rx, double ry, int fill, DrawThingTypes thing) |
Draw a little graphic in range X:x-rx..x+rx, Y:y-ry..y+ry. | |
virtual void | drawthing (double x, double y, double rx, double ry, DrawThingTypes thing, unsigned long fg, unsigned long bg, int lwidth=1) |
virtual void | drawarrow (flatpoint p, flatpoint v, int rfromp=0, double len=10, char reallength=1, int portion=3) |
Draw a little arrow near point p in v direction. | |
virtual void | drawaxes (double len=1) |
Draw the axes, x=red, y=green, real length len. | |
virtual void | drawnum (double x, double y, int num) |
Draw the number num centered at screen coord (x,y). | |
virtual int | font (LaxFont *nfont, double size=-1)=0 |
virtual int | font (const char *fontconfigpattern)=0 |
Set the current font to that specified. | |
virtual int | font (const char *family, const char *style, double size)=0 |
Set the current font to that specified. | |
virtual int | fontsize (double size)=0 |
Change the current font's size. | |
virtual int | textheight ()=0 |
Return the text height of the current font. | |
virtual double | textextent (LaxFont *thisfont, const char *str, int len, double *width, double *height, double *ascent, double *descent, char real)=0 |
Return the width of the text. | |
virtual double | textextent (const char *str, int len, double *width, double *height) |
Return the width of the text. | |
virtual double | textout (double x, double y, const char *str, int len=0, unsigned long align=LAX_CENTER)=0 |
Draw text at screen x,y. Return distance advanced. | |
virtual double | textout (double *matrix, double x, double y, const char *str, int len=0, unsigned long align=LAX_CENTER)=0 |
Draw transformed text starting at x,y. | |
virtual double | textout (double angle, double x, double y, const char *str, int len=0, unsigned long align=LAX_CENTER)=0 |
Draw text at an angle starting at x,y. | |
virtual int | imageout (LaxImage *image, double x, double y, double w, double h)=0 |
Output an image into a real space rectangle. | |
virtual void | imageout (LaxImage *img, double x, double y)=0 |
Output an image at x,y with no further transform. | |
virtual void | imageout (LaxImage *img, double *matrix)=0 |
virtual void | imageout (LaxImage *img, double angle, double x, double y)=0 |
virtual void | imageout_rotated (LaxImage *img, double x, double y, double ulx, double uly)=0 |
virtual void | imageout_skewed (LaxImage *img, double x, double y, double ulx, double uly, double urx, double ury)=0 |
Viewport maintenance functions: | |
virtual const double * | Getctm ()=0 |
Return a constant pointer to the current transformation matrix. | |
virtual const double * | Getictm ()=0 |
Return a constant pointer to the inverse of the current transformation matrix. | |
virtual int | righthanded () |
Return whether the ctm is (mathematically) right handed or not. | |
virtual char | Updates (char toupdatepanner) |
Call Updates(0) to disable updating the panner, Updates(1) to reenable it. | |
virtual void | syncPanner (int all=0) |
Using displayer viewable portion settings, set the panner settings. | |
virtual void | syncFromPanner (int all=0) |
Using the settings in the panner, try to set the Displayer bounds. | |
virtual void | UseThisPanner (PanController *npanner) |
Use the supplied PanController for bounds control. | |
virtual void | PushAxes ()=0 |
Push the current axes on the axessstack. | |
virtual void | PopAxes ()=0 |
Recover the last pushed axes. | |
virtual void | NewTransform (double a, double b, double c, double d, double x0, double y0)=0 |
Make the current transform correspond to the values. | |
virtual void | NewTransform (const double *d) |
Set the ctm to these 6 numbers, via NewTransform(d[0],d[1],d[2],d[3],d[4],d[5]). | |
virtual void | PushAndNewTransform (const double *m) |
Push axes, and multiply ctm by a new transform. | |
virtual void | PushAndNewAxes (flatpoint p, flatpoint x, flatpoint y) |
Push axes, and multiply ctm by a new basis, p,x,y are all in real units. | |
virtual void | NewAxis (flatpoint o, flatpoint xtip) |
Replace current transform wth a new orthogonal basis with origin o, xaxis unit corresponds to (xtip-o). | |
virtual void | NewAxis (flatpoint o, flatvector x, flatvector y) |
Replace current transform with origin o, with x and y as the new axes. | |
virtual void | ShiftScreen (int dx, int dy) |
Move the viewable portion by dx,dy screen units. | |
virtual void | ShiftReal (double dx, double dy) |
Move the screen by real dx,dy along the real axes. | |
virtual void | Center (double minx, double maxx, double miny, double maxy) |
Zoom and center the view on the given real bounds. | |
virtual void | Center (const double *m, DoubleBBox *bbox) |
Center the bbox bounds, after transforming by m. | |
virtual void | Center (DoubleBBox *bbox) |
Center the bbox bounds, which are in real coordinates. | |
virtual void | CenterPoint (flatpoint p) |
Centers the view at real point p. | |
virtual void | CenterReal () |
Make the center of Minx,Maxx... correspond to the real origin. | |
virtual void | Newangle (double angle, int dir=0, int dec=-1) |
Rotate around real origin so that the x axis has angle between it and the screen horizontal. | |
virtual void | Rotate (double angle, int x, int y, int dec=-1) |
Rotate by angle, about screen coordinate (x,y). | |
virtual void | Zoomr (double m, flatpoint p) |
Zoom around real point p. | |
virtual void | Zoom (double m, int x, int y) |
Zoom around screen point x,y. | |
virtual void | Zoom (double m) |
Zoom around the real origin. | |
virtual double | Getmag (int y=0) |
Return the current magnification, screen=Getmag*real. | |
virtual double | GetVMag (int x, int y) |
Return the magnification along the screen vector (x,y). (screen=mag*real) | |
virtual void | Newmag (double xs, double ys=-1) |
Set the xscale and the yscale, but preserve orientation, then syncPanner(). | |
virtual void | SetView (double minx, double maxx, double miny, double maxy) |
Set the view area to this section of the screen. | |
virtual int | SetSpace (double minx, double maxx, double miny, double maxy) |
Set the workspace bounds, return nonzero if successful. | |
virtual void | GetSpace (double *minx, double *maxx, double *miny, double *maxy) |
Get the real, not screen, workspace bounds. | |
virtual void | GetTransformedSpace (long *minx, long *maxx, long *miny, long *maxy) |
Find the mins and maxes of the transformed workspace. | |
Public Member Functions inherited from Laxkit::PanUser | |
PanUser (PanController *npan=NULL) | |
Create with a new panner. | |
virtual | ~PanUser () |
Removes this from panner tellstack. Delete panner if necessary. | |
virtual PanController * | createNewPanner (PanController *pan=NULL) |
Create a new panner that is a copy of pan if given. | |
Public Member Functions inherited from Laxkit::anObject | |
anObject () | |
Set object_id=getUniqueNumber(). | |
virtual | ~anObject () |
Empty virtual destructor. | |
virtual const char * | whattype () |
Returns the type of anObject. | |
virtual anObject * | duplicate (anObject *ref=NULL) |
virtual int | inc_count () |
Increment the data's count by 1. Returns count. | |
virtual int | dec_count () |
Decrement the count of the data, deleting if count is less than or equal to 0. | |
virtual int | the_count () |
Public Attributes | |
unsigned long | displayer_style |
double | upperbound |
The maximum screen length of an axis and other items. | |
double | lowerbound |
The minimum screen length of an axis and other items. | |
int | Minx |
Minimum screen x coordinate. | |
int | Maxx |
Maximum screen x coordinate. | |
int | Miny |
Minimum screen y coordinate (near top of screen). | |
int | Maxy |
Maximum screen y coordinate (near bottom of screen). | |
Public Attributes inherited from Laxkit::PanUser | |
PanController * | panner |
Public Attributes inherited from Laxkit::anObject | |
int | suppress_debug |
DeleteRefCountedFunc | deleteMe |
Called when the count is decremented to 0. | |
unsigned long | object_id |
char * | object_idstr |
Protected Attributes | |
anXWindow * | xw |
aDrawable * | dr |
int | on |
char | updatepanner |
double | spaceminx |
Minimum real workspace x coordinate. | |
double | spacemaxx |
Maximum real workspace x coordinate. | |
double | spaceminy |
Minimum real workspace y coordinate. | |
double | spacemaxy |
Maximum real workspace y coordinate. | |
char | draw_immediately |
char | real_coordinates |
char | decimal |
int | num_bez_div |
Protected Attributes inherited from Laxkit::anObject | |
int | _count |
The reference count of the object. |
A graphics drawing wrapper.
Handles drawing lines, bezier curves, ellipses (in any orientation, not just elongated horizontally and vertically), and viewport scaling, rotating, shifting.
Displayer classes are meant to draw onto random buffers, but also have ability to draw right onto windows.
There are the screen bounds, which are in screen window coordinates, defined by Minx, Maxx, Miny, and Maxy. Also there are workspace bounds in real coordinates, defined by spaceminx, spacemaxx, spaceminy, and spacemaxy. If the axes are rotated, then the actual contents of a window may show portions not in the workspace. The bounding rectangle of this rotated space (in screen window coords) is stored in the panner so that scrollers and such have access to something meaningful.
Any window tracking the bounds and viewable portion of the displayer are typcially informed via a PanController, which sends out a change message to any windows registered with it.
For any rulers tracking the workspace, care must be taken when the axes are of different lengths, and especially when the axes are rotated. Call GetVMag() to find out the magnification along the specified screen vector. Also when rotated, the workspace is a rotated rectangle, thus its screen bounding rectangle is a larger rectangle. This must be taken into account by any scroll bars that track the workspace.
*** this could be automated a little more, maybe the ruler could watch a panner too? or watch a displayer??? maybe not, rulers are doubles, panners are longs
*** have to coordinate panner->minsel/maxsel and upperbound/lowerbound.
***heell, perhaps combine displayer and panner to DoublePanner? would simplify some things...
*** require ctm and ictm be kept up always?? would make this just slightly faster
About the Current Transformation matrix (ctm) and its inverse (ictm):
Postscript: [ a b 0 ] CTM=[ c d 0 ] –> [a b c d tx ty] [ tx ty 1 ]
screen x= ax + cy + tx –> screen = [x',y',1] = [x,y,1] * CTM = real * CTM screen y= bx + dy + ty
Say you want to rotate real, then translate real, then screenp = realp*R*T*CTM.
In the Cairo library, cairo_matrix_t={ double xx,xy, yx,yy, x0,y0 } corresponds basically to [xx yx xy yy x0 y0].
Laxkit::Displayer::Displayer | ( | anXWindow * | nxw = NULL , |
PanController * | pan = NULL |
||
) |
Constructor, set everything to nothing or identity.
upperbound=1000, lowerbound=.00001, ctm/ictm=identity, fgcolor=white, bg=black
References lowerbound, Maxx, Maxy, Minx, Miny, spacemaxx, spacemaxy, spaceminx, spaceminy, and upperbound.
|
pure virtual |
Turn on or off the usage of double buffering.
Displayer::BackBuffer(int on)
Return whether there is an active clipping area (0 for no, nonzero for yes).
Implemented in Laxkit::DisplayerXlib, and Laxkit::DisplayerCairo.
|
pure virtual |
Set how to combine drawing elements to the target surface, return the old one.
See LaxCompositeOp.
Implemented in Laxkit::DisplayerXlib.
Referenced by Laxkit::drawing_function(), LaxInterfaces::ViewportWithStack::Refresh(), and LaxInterfaces::GradientInterface::Refresh().
|
virtual |
Zoom and center the view on the given real bounds.
This will not rotate the display, but will shift and scale to view properly. The axes aspect is maintained.
Uses Zoom() and CenterPoint(). Subclasses need not redefine.
References CenterPoint(), Maxx, Maxy, Minx, Miny, realtoscreen(), and Zoom().
|
virtual |
Center the bbox bounds, after transforming by m.
Finds transformed bounds, then calls Center(double minx,double maxx,double miny,double maxy).
References Center(), and Laxkit::transform_point().
|
virtual |
Center the bbox bounds, which are in real coordinates.
This just passes values on to Center(double,double,double,double).
References Center().
|
virtual |
Centers the view at real point p.
void Displayer::imageout_skewed(LaxImage *img,double x,double y,double ulx,double uly,double urx,double ury)
This finds the position of real point p on screen, then uses ShiftScreen() to center it.
References Maxx, Maxy, Minx, Miny, realtoscreen(), and ShiftScreen().
Referenced by Center(), CenterReal(), LaxInterfaces::ViewportWindow::MoveResize(), and LaxInterfaces::ViewportWindow::Resize().
|
virtual |
Make the center of Minx,Maxx... correspond to the real origin.
This just calls CenterPoint(flatpoint(0,0)).
References CenterPoint().
Referenced by LaxInterfaces::ViewportWindow::init(), LaxInterfaces::ViewportWindow::MoveResize(), and LaxInterfaces::ViewportWindow::Resize().
Set the clipping area to the path defined by the given polyline.
Return 0 for success, nonzero for error.
Implemented in Laxkit::DisplayerXlib, and Laxkit::DisplayerCairo.
Clear the old surface, and create a fresh surface to perform drawing operations on.
Return 0 for successful creation, or nonzero for unable to do so.
Implemented in Laxkit::DisplayerXlib, and Laxkit::DisplayerCairo.
|
virtual |
Interpret all angles as radians.
Sets decimal=1.
|
virtual |
Draw part of an ellipse.
Just calls drawellipse() with no fill. Subclasses need not redefine.
References drawellipse().
Referenced by Laxkit::draw_arc(), and Laxkit::DisplayerCairo::drawpoint().
|
virtual |
Draw a little arrow near point p in v direction.
p is center of a circle radius rfromp, and the arrow is drawn tangent to the circle. rfromp<0 means arrow is on ccw side.
Currently, the length of the arrow is screen pixel length len if reallengthi==0. If reallength==1, then the length is the absolute real length len. If reallength==2, the arrow draws with a length norm(v)*len.
This uses drawline() to draw the arrow. Subclasses need not redefine.
If portion&1, draw half of the arrow head. If portion&2, draw the other half. So portion==3 draws whole arrow head.
References drawline(), norm(), realtoscreen(), and transpose().
Referenced by LaxInterfaces::PatchInterface::drawControlPoints(), LaxInterfaces::GradientInterface::Refresh(), LaxInterfaces::RectInterface::Refresh(), and LaxInterfaces::PathInterface::Refresh().
|
virtual |
Draw the axes, x=red, y=green, real length len.
This will set the color, but not other line attributes.
References drawline(), DrawReal(), DrawScreen(), and NewFG().
Referenced by LaxInterfaces::ViewportWithStack::Refresh().
|
virtual |
Draw a cubic bezier line.
This is the usual actual bez having f'=3*(control point dist) which displays the remarkable midpoint property....
For t in [0,1] from vertex v1, controls c1,c2, then vertex v2: p(t) = (1-t)^3 * v1 + 3t(1-t)^2 * c1 + 3*t^2*(1-t) * c2 + t^3 * v2;
assumes n=(num vertex points), and that there are n*3 points in bpoints. If i is in range [0..n*3], then i%3=1 are v, i%3=0 c1,i%3=2 c2: c-v-c - c-v-c - c-v-c ... The first and final control point in bpoints are not accessed unless isclosed!=0.
This function uses curveto(), and fill()/stroke() if draw_immediately. Subclasses don't have to redefine if that is sufficient.
If fill==0 then draw only the line. If fill==1 then draw only the fill. If fill==2 then draw line with fgcolor, and fill with bgcolor
References closed(), curveto(), fill(), NewFG(), and stroke().
Referenced by LaxInterfaces::PathInterface::drawNewPathIndicator(), drawthing(), LaxInterfaces::RectInterface::Refresh(), and LaxInterfaces::PatchInterface::Refresh().
|
virtual |
Draw an ellipse with center at real point p..
This ellipse is (xr*(x-p.x))^2 + (yr*(y-p.y))^2 = 1. If f is distance from center to a focus, then f=sqrt(xr*xr-yr*yr) if xr>yr, swap if yr<xr.
This function just calls drawfocusellipse() with appropriate settings.
Referenced by drawarc(), and LaxInterfaces::PathInterface::drawNewPathIndicator().
|
virtual |
Draw an ellipse in the rectangle spanned by p +/- (xradius,yradius).
If start and end angles don't correspond, then draw a partial ellipse, filled as a pie slice.
References drawfocusellipse().
|
virtual |
Draw an ellipse based on the foci.
en=st==0 means draw whole thing.
If fill==0 then draw only the line. If fill==1 then draw only the fill. If fill==2 then draw line with fgcolor, and fill with bgcolor
c | Dist from focus to point on ellipse to other focus is c |
start_angle | The starting angle |
end_angle | The ending angle |
tofill | how to fill |
References Laxkit::bez_ellipse(), closed(), curveto(), fill(), NewFG(), stroke(), and transpose().
Referenced by drawellipse().
Do not append path operations, draw them with each call.
Sets draw_immediately to yes. Returns old value of draw_immediately.
Referenced by Laxkit::DisplayerCairo::Clip(), and LaxInterfaces::PathInterface::Refresh().
|
virtual |
Draw a line between coordinates (ax,ay) and (bx,by).
Just calls drawline(flatpoint,flatpoint). Subclasses need not redefine.
Reimplemented in Laxkit::DisplayerXlib.
References drawline().
|
pure virtual |
Draw a polygon, optionally closed, optionally fill, optionally transform.
If fill==1 then fill with FG and have no border. If fill==2, then fill with BG and border with FG.
Implemented in Laxkit::DisplayerXlib, and Laxkit::DisplayerCairo.
Referenced by Laxkit::draw_bevel(), Laxkit::draw_lines(), LaxInterfaces::PatchInterface::drawpatch(), LaxInterfaces::GradientInterface::drawRadial(), LaxInterfaces::GradientInterface::drawRadialLine(), drawthing(), Laxkit::fill_polygon(), LaxInterfaces::ImagePatchInterface::patchpoint(), LaxInterfaces::ColorPatchInterface::patchpoint2(), LaxInterfaces::ObjectInterface::Refresh(), LaxInterfaces::ImageInterface::Refresh(), and LaxInterfaces::RectInterface::Refresh().
|
virtual |
Draw the number num centered at screen coord (x,y).
If (x,y) is not on the screen, draw nothing.
If the coordinate is near a screen edge, care is taken so that the number will actually be drawn entirely in the screen, and not bleed off the edge.
References Maxx, Maxy, Minx, Miny, onscreen(), textextent(), and textout().
Referenced by drawrealline().
|
virtual |
Subclasses must redefine this is modifying the mask is ok.
Default does nothing.
Reimplemented in Laxkit::DisplayerCairo.
|
virtual |
Ensure that drawing operations work on source (as opposed to mask).
Default does nothing.
Reimplemented in Laxkit::DisplayerCairo.
Draw a little circle at p with screen radius.
If fill==0 then draw only the line. If fill==1 then draw only the fill. If fill==2 then draw line with fgcolor, and fill with bgcolor
This just calls the other drawpoint(p.x,p.y,radius,fill).
References drawpoint().
|
virtual |
Any subsequent calls are using real coordinates.
Returns old real_coordinates.
Reimplemented in Laxkit::DisplayerXlib.
Referenced by drawaxes(), LaxInterfaces::ColorPatchInterface::drawControlPoint(), LaxInterfaces::GradientInterface::drawLinear(), LaxInterfaces::PathInterface::drawNewPathIndicator(), LaxInterfaces::PatchInterface::drawpatch(), LaxInterfaces::GradientInterface::drawRadial(), LaxInterfaces::GradientInterface::drawRadialLine(), LaxInterfaces::ImagePatchInterface::patchpoint(), LaxInterfaces::ColorPatchInterface::patchpoint2(), LaxInterfaces::ViewportWithStack::Refresh(), LaxInterfaces::CaptionInterface::Refresh(), LaxInterfaces::ImageInterface::Refresh(), LaxInterfaces::GradientInterface::Refresh(), LaxInterfaces::RectInterface::Refresh(), and LaxInterfaces::PathInterface::Refresh().
Draw a line across the whole view, and if num!=-10000000, print the number num where the line hits the sides of the window.
Return the number of intersections the line makes with the screen.
This uses drawnum() and drawline(), and subclasses need not redefine.
References drawline(), drawnum(), Maxx, Maxy, Minx, Miny, realtoscreen(), and segmentandline().
|
virtual |
Draw a basic rectangle.
If fill==0 then draw only the line. If fill==1 then draw only the fill. If fill==2 then draw line with fgcolor, and fill with bgcolor
References closed(), fill(), NewFG(), and stroke().
Referenced by Laxkit::draw_rectangle(), and Laxkit::fill_rectangle().
|
virtual |
Any subsequent calls are using screen coordinates.
Returns old real_coordinates.
Reimplemented in Laxkit::DisplayerXlib.
Referenced by drawaxes(), LaxInterfaces::ColorPatchInterface::drawControlPoint(), LaxInterfaces::GradientInterface::drawLinear(), LaxInterfaces::PathInterface::drawNewPathIndicator(), LaxInterfaces::GradientInterface::drawRadial(), LaxInterfaces::GradientInterface::drawRadialLine(), LaxInterfaces::ImagePatchInterface::patchpoint(), LaxInterfaces::ColorPatchInterface::patchpoint2(), LaxInterfaces::CaptionInterface::Refresh(), LaxInterfaces::ImageInterface::Refresh(), LaxInterfaces::GradientInterface::Refresh(), LaxInterfaces::RectInterface::Refresh(), and LaxInterfaces::PathInterface::Refresh().
|
virtual |
Draw a little graphic in range X:x-rx..x+rx, Y:y-ry..y+ry.
This uses Laxkit::draw_thing_coordinates() to draw from.
References closed(), Laxkit::draw_thing_coordinates(), drawbez(), and drawlines().
Referenced by Laxkit::draw_thing(), LaxInterfaces::RectInterface::Refresh(), and LaxInterfaces::PathInterface::Refresh().
|
pure virtual |
Set everything assuming we do not need to draw on the current surface for the time being.
Updates(1) must be called, so that further changes to the viewport will be sent to the panner.
This resets all the drawing bits to 0 to prevent calls made from non-window elements trying to use windows that might have been destroyed. Unfortunately, such error checking for drawing bits set to 0 is hardly implemented in Displayer drawing functions.. Displayer needs more work...
If xw==NULL, then call Updates(1);
Implemented in Laxkit::DisplayerXlib, and Laxkit::DisplayerCairo.
Referenced by LaxInterfaces::ViewportWithStack::Refresh(), and LaxInterfaces::ViewportWindow::Refresh().
fillrule can be EvenOddRule or WindingRule. fillstyle can be FillSolid, FillTiled, FillStippled, or FillOpaqueStippled.
Implemented in Laxkit::DisplayerXlib.
Referenced by LaxInterfaces::PathInterface::Refresh().
|
virtual |
Return the current magnification, screen=Getmag*real.
If y!=0 then return the y scale, default is to return the x scale.
Note that this only returns basically length of axis in screen units divided by length of axis in real coords. If the axes are not at a right angle to each other, they do not correspond necessarily to the screen horizontal or vertical magnification. For that, call GetVMag.
Reimplemented in Laxkit::DisplayerXlib.
References Getctm().
Referenced by LaxInterfaces::anInterface::Getmag(), LaxInterfaces::ViewportWindow::Getmag(), LaxInterfaces::EngraverFillInterface::newPatchData(), LaxInterfaces::PathInterface::Refresh(), LaxInterfaces::EllipseInterface::scan(), LaxInterfaces::PointWarpInterface::scan(), and LaxInterfaces::PatchInterface::scan().
|
virtual |
Get the real, not screen, workspace bounds.
Note that if the real space is rotated, the returned values here are the actual real coordinates for the bounds. For a rectangled aligned with the screen, use GetTransformedSpace().
|
pure virtual |
Return a new LaxImage that is copied from the current buffer.
Returned image has count of 1.
The particular type of LaxImage will usually depend on the particular type of Displayer.
Implemented in Laxkit::DisplayerXlib.
|
virtual |
Find the mins and maxes of the transformed workspace.
It is ok to have some of the pointers NULL.
Note that these will be different values from GetSpace() when the viewing space is rotated.
References realtoscreen(), spacemaxx, spacemaxy, spaceminx, and spaceminy.
Referenced by syncPanner().
Return the magnification along the screen vector (x,y). (screen=mag*real)
This is useful when the axes are of different lengths or are not orthogonal, or are rotated.
It is doing this:
Reimplemented in Laxkit::DisplayerXlib.
References screentoreal().
Referenced by LaxInterfaces::anInterface::GetVMag(), LaxInterfaces::ViewportWindow::GetVMag(), and LaxInterfaces::ViewportWindow::syncrulers().
|
pure virtual |
Output an image into a real space rectangle.
This will obey any clipping in place.
(x,y) is an additional translation to use. If w>0 AND h>0, then fit the image into a rectangle with those real width and height. If w<=0 or h<=0, then use the image's pixel width and height as bounds.
Return 0 for image drawn with no complications.
When there is an error and nothing is drawn, a negative value is returned. Return -1 for image==NULL. Return -2 for unknown image type. Return -3 for image not available.
When drawing effectively succeeds, but there are extenuating circumstances, a positive value is returned. Return 1 for image not in viewport, so it's not actually drawn. Return 2 for image would be drawn smaller than a pixel, so it's not actually drawn.
Implemented in Laxkit::DisplayerXlib.
Referenced by LaxInterfaces::ImageInterface::Refresh(), LaxInterfaces::GradientInterface::Refresh(), LaxInterfaces::PointWarpInterface::Refresh(), and LaxInterfaces::PatchInterface::Refresh().
Set the width, whether solid, line cap and join.
width is only in screen pixels for now. See LaxJoinStyle and LaxCapStyle for values for cap and join. dash can be LineSolid, LineOnOffDash, or LineDoubleDash.
Implemented in Laxkit::DisplayerXlib, and Laxkit::DisplayerCairo.
Referenced by Laxkit::drawing_line_attributes(), LaxInterfaces::PathInterface::drawNewPathIndicator(), LaxInterfaces::PatchInterface::drawpatch(), LaxInterfaces::ViewportWithStack::Refresh(), LaxInterfaces::ObjectInterface::Refresh(), LaxInterfaces::FreehandInterface::Refresh(), LaxInterfaces::CaptionInterface::Refresh(), LaxInterfaces::ImageInterface::Refresh(), LaxInterfaces::GradientInterface::Refresh(), LaxInterfaces::RectInterface::Refresh(), LaxInterfaces::PointWarpInterface::Refresh(), LaxInterfaces::PatchInterface::Refresh(), and LaxInterfaces::PathInterface::Refresh().
|
pure virtual |
Add a segment to the current path.
If there was no previous point, then this is the same as a moveto(p).
Implemented in Laxkit::DisplayerXlib.
Replace current transform wth a new orthogonal basis with origin o, xaxis unit corresponds to (xtip-o).
This just does NewAxis(o,xtip-o,transpose(xtip-o)).
References transpose().
Referenced by Laxkit::DisplayerXlib::PushAndNewAxes(), and PushAndNewAxes().
|
virtual |
Replace current transform with origin o, with x and y as the new axes.
If x is parallel to y, then nothing is done.
Checks for that, then calls NewTransform( x.x,x.y, y.x,y.y, o.x,o.y,).
References NewTransform().
|
virtual |
Set the xscale and the yscale, but preserve orientation, then syncPanner().
If ys<=0, then the y scale is set the same as the xscale.
Reimplemented in Laxkit::DisplayerXlib.
References Getctm(), NewTransform(), and Laxkit::transform_copy().
Referenced by LaxInterfaces::ViewportWindow::init().
|
pure virtual |
Make the current transform correspond to the values.
Replace current transform with new, then must syncPanner().
Implemented in Laxkit::DisplayerXlib, and Laxkit::DisplayerCairo.
Referenced by Newangle(), NewAxis(), Newmag(), NewTransform(), PushAndNewTransform(), ShiftReal(), ShiftScreen(), syncFromPanner(), LaxInterfaces::ViewportWindow::ViewportWindow(), and Zoom().
Push axes, and multiply ctm by a new basis, p,x,y are all in real units.
Simply a shortcut for:
Reimplemented in Laxkit::DisplayerXlib.
References NewAxis(), and PushAxes().
|
virtual |
Push axes, and multiply ctm by a new transform.
So newctm=m*ctm. Default is to use Getctm(), then NewTransform(double*) with the new matrix.
Reimplemented in Laxkit::DisplayerXlib.
References Getctm(), NewTransform(), PushAxes(), and Laxkit::transform_mult().
Referenced by LaxInterfaces::ViewportWithStack::Refresh(), LaxInterfaces::ObjectInterface::Refresh(), LaxInterfaces::CaptionInterface::Refresh(), LaxInterfaces::ViewportWindow::Refresh(), LaxInterfaces::RectInterface::Refresh(), and LaxInterfaces::PathInterface::Refresh().
|
virtual |
Interpret all angles as radians.
Sets decimal=0.
Convert real point p to screen coordinates.
screen x= ax + cy + tx –> screen = [x',y',1] = [x,y,1] * CTM = real * CTM screen y= bx + dy + ty
So basically this should return:
Implemented in Laxkit::DisplayerXlib, and Laxkit::DisplayerCairo.
Referenced by Center(), CenterPoint(), drawarrow(), LaxInterfaces::ColorPatchInterface::drawControlPoint(), LaxInterfaces::GradientInterface::drawLinear(), LaxInterfaces::PathInterface::drawNewPathIndicator(), LaxInterfaces::ColorPatchInterface::drawpatch(), LaxInterfaces::ImagePatchInterface::drawpatch(), LaxInterfaces::GradientInterface::drawRadial(), LaxInterfaces::GradientInterface::drawRadialLine(), drawrealline(), LaxInterfaces::RectInterface::GetOuterRect(), GetTransformedSpace(), LaxInterfaces::anInterface::realtoscreen(), LaxInterfaces::ViewportWindow::realtoscreen(), LaxInterfaces::PathInterface::realtoscreen(), LaxInterfaces::CaptionInterface::Refresh(), LaxInterfaces::ImageInterface::Refresh(), LaxInterfaces::GradientInterface::Refresh(), LaxInterfaces::RectInterface::Refresh(), LaxInterfaces::PathInterface::Refresh(), Rotate(), LaxInterfaces::RectInterface::scan(), LaxInterfaces::ViewportWindow::syncrulers(), Zoom(), and Zoomr().
|
pure virtual |
Convert real point (x,y) to screen coordinates.
Just return realtoscreen(flatpoint(x,y)).
Implemented in Laxkit::DisplayerXlib, and Laxkit::DisplayerCairo.
References Getctm().
Resize an internal drawing surface.
If you had previously called CreateSurface(), this will resize that surface. If the target surface is an external surface, then nothing is done.
Return 0 for success, or 1 if not using an internal surface, and nothing done.
Implemented in Laxkit::DisplayerXlib, and Laxkit::DisplayerCairo.
|
virtual |
Return whether the ctm is (mathematically) right handed or not.
Note that for typical X displays, how it appears to the user is left handed, when mathematically it is really right handed. This function returns whether the ctm is mathematically right handed.
References Getctm().
Referenced by LaxInterfaces::ImageInterface::Refresh(), and LaxInterfaces::ViewportWindow::UseTheseRulers().
Rotate by angle, about screen coordinate (x,y).
dec nonzero means angle is degrees, otherwise radians.
Reimplemented in Laxkit::DisplayerXlib.
References Newangle(), realtoscreen(), screentoreal(), and ShiftScreen().
Referenced by LaxInterfaces::ViewportWindow::MouseMove().
|
virtual |
Set the workspace bounds, return nonzero if successful.
Returns 1 if successful and viewable area not changed.
Returns 2 if successful and viewable are is changed.
Please note that checking whether the viewable area is changed is not implemented. Currently, assumes that it is and returns 2.
Basically sets spacemin/max (ensuring that min is actually < max), then calles syncPanner(1). Subclasses should redefine if special care is needed.
References Maxx, Maxy, Minx, Miny, spacemaxx, spacemaxy, spaceminx, spaceminy, and syncPanner().
Referenced by LaxInterfaces::ViewportWindow::SetSpace(), and LaxInterfaces::ViewportWindow::ViewportWindow().
|
virtual |
Set the view area to this section of the screen.
Basically, say there's a box in screen coordinates that you want to zoom in on, within the screen bounds given. The viewport will be zoomed so that that area is expanded (or shrunk) to fill the viewport.
Transforms the screen box into a real box, then uses Center(double minx,double maxx,double miny,double maxy).
Min/Maxx/y will not be changed, but afterwards they will correspond to these bounds. This is essentially a more complicated form of zooming.
|
virtual |
Move the screen by real dx,dy along the real axes.
Finds the appropriate transform, then NewTransform(newctm).
The new transform is basically:
Reimplemented in Laxkit::DisplayerXlib.
References Getctm(), NewTransform(), and Laxkit::transform_copy().
Move the viewable portion by dx,dy screen units.
This finds the new transform then sets with NewTransform().
In essence, do this:
Reimplemented in Laxkit::DisplayerXlib, and Laxkit::DisplayerCairo.
References Getctm(), NewTransform(), and Laxkit::transform_copy().
Referenced by CenterPoint(), LaxInterfaces::ViewportWindow::MouseMove(), Rotate(), LaxInterfaces::ViewportWindow::WheelDown(), LaxInterfaces::ViewportWindow::WheelUp(), Zoom(), and Zoomr().
Set up to be drawing on a buffer.
An important trait of starting drawing with this is that Updates(0) is always in effect until EndDrawing is called. Calling this start is when you want to draw a bunch of stuff on any old pixmap, and not fuss with the panner things.
Sets Minx=Miny=0, Maxx=width, Maxy=height of drawable.
If xw==NULL when EndDrawing() is called, then Updates(1) is called. Please remember, however, that the Minx,Maxx,... are screwed up by then, and you must sync those yourself.
Implemented in Laxkit::DisplayerXlib, and Laxkit::DisplayerCairo.
Referenced by LaxInterfaces::ViewportWithStack::Refresh(), and LaxInterfaces::ViewportWindow::Refresh().
|
virtual |
Using the settings in the panner, try to set the Displayer bounds.
This would occur, for instance, on a "pan change" event resulting from a scroller move. The panner does not implement rotating, so any changes would be from a page size change or a straight move in screen x or y directions. Thus the panner wholespace has not changed its values, but the panner selbox has.
panner contains the transformed workspace coords. Real space=ictm*twc. So we must find a new transform so that the space fits the panner settings. If the displayer's axes must remain the same length, care must be taken to ensure that, since the panner uses integers, which introduce rounding errors.
This function is not called from within the Displayer. A holding window (such as ViewportWindow) would call it upon receipt of a "pan change".
Subclasses should call this, then update from ctm/ictm if necessary.
References Laxkit::dumpctm(), Getctm(), Laxkit::PanController::GetCurPos(), Maxx, Maxy, Minx, Miny, NewTransform(), screentoreal(), syncPanner(), and Laxkit::transform_copy().
Referenced by LaxInterfaces::ViewportWindow::Event().
|
virtual |
Using displayer viewable portion settings, set the panner settings.
If all is nonzero, then set curpos and space in panner. Otherwise just set the curpos.
panner is not directly accessed, except in WrapWindow, here, and in syncFromPanner. When telling the panner there have been changes (by setting panner stuff here), the displayer does not want to receive a "pan change" from the panner***
References Laxkit::PanController::dontTell(), GetTransformedSpace(), Maxx, Maxy, Minx, Miny, Laxkit::PanController::SetCurPos(), Laxkit::PanController::SetSelBounds(), and Laxkit::PanController::SetWholebox().
Referenced by LaxInterfaces::ViewportWindow::init(), LaxInterfaces::ViewportWindow::MoveResize(), Laxkit::DisplayerXlib::Newangle(), Laxkit::DisplayerXlib::Newmag(), Laxkit::DisplayerCairo::NewTransform(), Laxkit::DisplayerXlib::NewTransform(), LaxInterfaces::ViewportWindow::Resize(), Laxkit::DisplayerXlib::Rotate(), SetSpace(), Laxkit::DisplayerXlib::ShiftReal(), Laxkit::DisplayerCairo::ShiftScreen(), Laxkit::DisplayerXlib::ShiftScreen(), syncFromPanner(), LaxInterfaces::ViewportWindow::UseTheseScrollers(), UseThisPanner(), WrapWindow(), Laxkit::DisplayerXlib::Zoom(), and Laxkit::DisplayerXlib::Zoomr().
|
pure virtual |
Return the width of the text.
Use thisfont if given (but do not set the default font), or the default font if NULL.
Also return width, height, ascent, and descent if not null.
If real==0, then return ascent+descent for height. Else return the visual extent of the string.
Extents depend on draw_real.
Implemented in Laxkit::DisplayerCairo.
Referenced by drawnum(), Laxkit::getextent(), LaxInterfaces::CaptionInterface::Refresh(), Laxkit::CurveWindow::SetupRect(), and textextent().
|
virtual |
Return the width of the text.
This just calls the other textextent(). Also return width and height if not null. Extents depend on draw_real.
References textextent().
Call Updates(0) to disable updating the panner, Updates(1) to reenable it.
This is used during refreshing, when there is constant pushing and popping of the transform. Just sets a flag so that syncPanner returns before doing anything.
The programmer is responsible for balancing the push/pop of axes so that when updates are activated, the displayer and panner are still synced.
Returns the old value of updatepanner.
Referenced by Laxkit::DisplayerCairo::EndDrawing(), Laxkit::DisplayerXlib::EndDrawing(), LaxInterfaces::ViewportWindow::Refresh(), and Laxkit::DisplayerXlib::StartDrawing().
|
virtual |
Use the supplied PanController for bounds control.
Displayer overwrites the values in the panner to correspond to the displayer values. The whole space of the panner corresponds to the transformed displayer workspace in screen window coords scaled to [-1000000,1000000].
Basically, dose UseThisPanner() then syncPanner(1).
Reimplemented from Laxkit::PanUser.
References syncPanner().
Referenced by LaxInterfaces::ViewportWindow::ViewportWindow().
|
virtual |
Set the viewable portion of the displayer to correspond with the window's win_w and win_h.
So Minx,Maxx,Miny,Maxy==0,win_w, 0,win_h Also sets the panner boxaspect to correspond to the window proportions. Call syncPanner() to update anything attached to it.
If the spacemin/max seem not to be set, then set things so that the whole space is 10 times the window size, and the viewable portion is in the middle.
PLEASE NOTE this does not do anything but set Min/Max, spacemin/max, mainly for panner upkeep. Other drawing targets or other state would be done in StartDrawing().
References Laxkit::PanController::dontTell(), Maxx, Maxy, Minx, Miny, Laxkit::PanController::SetBoxAspect(), spacemaxx, spacemaxy, spaceminx, spaceminy, and syncPanner().
Referenced by LaxInterfaces::ViewportWindow::init(), LaxInterfaces::ViewportWindow::MoveResize(), and LaxInterfaces::ViewportWindow::Resize().