Laxkit  0.0.7.1
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions
Laxkit::DisplayerXlib Class Reference

Somewhat of a graphics wrapper for Xlib graphics functions. More...

Inheritance diagram for Laxkit::DisplayerXlib:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 DisplayerXlib (aDrawable *d)
 Return a constant pointer to the current transformation matrix.
 DisplayerXlib (anXWindow *w=NULL, PanController *pan=NULL)
 Constructor, set everything to nothing or identity.
virtual ~DisplayerXlib ()
 Destructor, delete ctm.
virtual Displayerduplicate ()
Window and Xlib specific helper functions:
virtual Display * GetDpy ()
virtual aDrawableGetXw ()
virtual Drawable GetXDrawable ()
virtual GC GetGC ()
XftDraw * textdraw (Window xlib_window)
 Return the application's default Xft text drawing context.
Buffer Management
virtual void SwapBuffers ()
virtual void BackBuffer (int on)
 Turn on or off the usage of double buffering.
virtual int StartDrawing (aDrawable *buffer)
 Set up to be drawing on a buffer.
virtual int MakeCurrent (aDrawable *buffer)
virtual int ClearDrawable (aDrawable *drawable)
 Free any data associated with drawable.
virtual int CreateSurface (int width, int height, int type=-1)
 Create a fresh surface to perform drawing operations on.
virtual LaxImageGetSurface ()
 Return a new LaxImage that is copied from the current buffer.
virtual int ResizeSurface (int width, int height)
 Resize an internal drawing surface.
virtual int EndDrawing ()
 Sets gc,w,on all to 0.
State
virtual unsigned long NewFG (double r, double g, double b, double a=1.0)
 Set new foreground color. Typically usage is NewFG(app->rgbcolor(.5,.8,0,1.0)).
virtual unsigned long NewFG (unsigned long ncol)
 Set new foreground. Typically usage is NewFG(app->rgbcolor(23,34,234)).
virtual unsigned long NewFG (ScreenColor *col)
 Set new foreground. Color components are 0..0xffff.
virtual unsigned long NewFG (int r, int g, int b, int a=255)
 Set new foreground. Typically usage is NewFG(app->rgbcolor(23,34,234)).
virtual unsigned long NewBG (double r, double g, double b)
 Set new background color. Typically usage is NewFG(app->rgbcolor(.5,.8,0)).
virtual unsigned long NewBG (int r, int g, int b)
 Set new background. Typically usage is NewBG(app->rgbcolor(23,34,234)).
virtual unsigned long NewBG (unsigned long nc)
 Set new background. Typically usage is NewBG(app->rgbcolor(23,34,234)).
virtual unsigned long FG ()
virtual unsigned long BG ()
virtual void LineAttributes (double width, int dash, int cap, int join)
 Set the width, whether solid, line cap and join.
virtual void FillAttributes (int fillstyle, int fillrule)
virtual LaxCompositeOp BlendMode (LaxCompositeOp mode)
 Set how to combine drawing elements to the target surface.
Main drawing functions:
virtual void ClearWindow ()
 Clear the window to bgcolor between Min* and Max*.
virtual flatpoint realtoscreen (flatpoint p)
 Convert real point p to screen coordinates.
virtual flatpoint realtoscreen (double x, double y)
 Convert real point (x,y) to screen coordinates.
virtual flatpoint screentoreal (int x, int y)
 Convert screen point (x,y) to real coordinates.
virtual flatpoint screentoreal (flatpoint p)
 Convert screen point p to real coordinates.
virtual int Clip (flatpoint *p, int n, int append)
virtual void PushClip (int startfresh)
 Push the current clip mask onto a stack, make a new one maybe.
virtual void PopClip ()
 Restore a previous mask.
virtual void ClearClip ()
 Clears clipregion, clipmask, and calls XSetClipMask(GetDpy(),GetGC(),None).
virtual int activeMask ()
 Return whether there is an active clipping area.
virtual int DrawReal ()
 Any subsequent calls are using real coordinates.
virtual int DrawScreen ()
 Any subsequent calls are using screen coordinates.
virtual void DrawOnMask ()
virtual void DrawOnSrc ()
virtual void show ()
 Flush waiting composite operation.
virtual void fill (int preserve)
virtual void stroke (int preserve)
virtual void moveto (flatpoint p)
virtual void lineto (flatpoint p)
virtual void curveto (flatpoint c1, flatpoint c2, flatpoint v)
virtual void closed ()
 Call if current path should be closed, and close at the last added point.
virtual void closeopen ()
 Call if current path should be ended, but not closed.
virtual void drawpixel (flatpoint p)
 Draw one pixel at coord p.
virtual void drawpoint (double x, double y, double radius, int fill)
 Draw a little circle at screen coord (x,y) with radius r.
virtual void drawlines (flatpoint *points, int npoints, char closed, char fill)
 Draw a polygon, optionally closed, optionally fill, optionally transform.
virtual void drawline (flatpoint p1, flatpoint p2)
 Draw a line between real coordinates p1 and p2.
virtual void drawline (double ax, double ay, double bx, double by)
 Draw a line between screen coordinates (ax,ay) and (bx,by).
virtual int textheight ()
 Return the text height of the current font.
virtual int font (LaxFont *nfont, double size=-1)
virtual int font (const char *fontconfigpattern)
virtual int font (const char *family, const char *style, double pixelsize)
virtual int fontsize (double size)
virtual double textextent (LaxFont *thisfont, const char *str, int len, double *width, double *height, double *ascent, double *descent, char real)
virtual double textout_line (double x, double y, const char *str, int len=0, unsigned long align=LAX_CENTER)
virtual double textout (double x, double y, const char *str, int len=0, unsigned long align=LAX_CENTER)
 Draw multiple lines of text around screen x,y.
virtual double textout (double *matrix, double x, double y, const char *str, int len=0, unsigned long align=LAX_CENTER)
virtual double textout (double angle, double x, double y, const char *str, int len=0, unsigned long align=LAX_CENTER)
virtual int imageout (LaxImage *image, double x, double y, double w, double h)
 Output an image into a real space rectangle.
virtual void imageout (LaxImage *img, double x, double y)
virtual void imageout (LaxImage *img, double *matrix)
virtual void imageout (LaxImage *img, double angle, double x, double y)
virtual void imageout_rotated (LaxImage *img, double x, double y, double ulx, double uly)
virtual void imageout_skewed (LaxImage *img, double ulx, double uly, double urx, double ury, double llx, double lly)
Viewport maintenance functions:
virtual double * m ()
 Return pointer to the displayer's transformation matrix.
virtual const double * Getctm ()
virtual const double * Getictm ()
virtual void findictm ()
 Set the inverse of the current transformation matrix, assuming ctm is already set.
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 NewTransform (const double *d)
 Set the ctm to these 6 numbers.
virtual void NewTransform (double a, double b, double c, double d, double x0, double y0)
 Make the transform correspond to the values.
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 PushAxes ()
 Push the current axes on the axessstack.
virtual void PopAxes ()
 Recover the last pushed axes.
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 Newmag (double xs, double ys=-1)
 Set the xscale and the yscale.
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 c=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)
- Public Member Functions inherited from Laxkit::Displayer
 Displayer (aDrawable *d)
 Displayer (anXWindow *w=NULL, PanController *pan=NULL)
 Constructor, set everything to nothing or identity.
virtual ~Displayer ()
 Destructor.
virtual aDrawableGetDrawable ()
virtual void WrapWindow (anXWindow *nw)
 Set the viewable portion of the displayer to correspond with the window's win_w and win_h.
virtual void Radians ()
 Interpret all angles as radians.
virtual void Degrees ()
 Interpret all angles as radians.
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 moveto (double x, double y)
virtual void lineto (double x, double y)
virtual void drawpoint (flatpoint p, double radius, int fill)
 Draw a little circle at p with screen radius.
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 double textextent (const char *str, int len, double *width, double *height)
 Return the width of the text.
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 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 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 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 PanControllercreateNewPanner (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 charwhattype ()
 Returns the type of anObject.
virtual anObjectduplicate (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 ()

Protected Member Functions

virtual int Clip (Region newregion, int append)
virtual void buildXPoints ()
 Rebuild xpoints to correspond to the current path, if any.

Protected Attributes

Display * dpy
Window w
Visual * vis
GC gc
int isinternal
XftFont * xfont
XftFont * tempfont
LaxFontlaxfont
XftDraw * textxftdraw
Region clipregion
Pixmap clipmask
NumStack< Region > clipstack
NumStack< flatpointcurpoints
NumStack< intmultiplepaths
NumStack< intmultipleclosedpaths
XPoint * xpoints
int needtobuildxpoints
int maxxpoints_allocated
int numxpoints
int num_bez_div
double * ctm
 Current Transformation Matrix.
double ictm [6]
 Inverse Current Transformation Matrix.
PtrStack< double > axesstack
 The stack of axes. See PushAxes() and PopAxes().
unsigned long fgcolor
unsigned long bgcolor
ScreenColor fg
ScreenColor bg
LaxCompositeOp drawmode
- Protected Attributes inherited from Laxkit::Displayer
anXWindowxw
aDrawabledr
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
- Protected Attributes inherited from Laxkit::anObject
int _count
 The reference count of the object.

Private Member Functions

void base_init ()

Additional Inherited Members

- Public Attributes inherited from Laxkit::Displayer
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
PanControllerpanner
- Public Attributes inherited from Laxkit::anObject
int suppress_debug
DeleteRefCountedFunc deleteMe
 Called when the count is decremented to 0.
unsigned long object_id
charobject_idstr

Detailed Description

Somewhat of a graphics wrapper for Xlib graphics functions.

Handles drawing lines, bezier curves, ellipses (in any orientation, not just elongated horizontally and vertically), and viewport scaling, rotating, shifting.

DisplayerXlib classes are meant to draw onto random buffers, but also have ability to draw right onto an Xlib drawable.


Constructor & Destructor Documentation

Laxkit::DisplayerXlib::DisplayerXlib ( aDrawable d)

Return a constant pointer to the current transformation matrix.

fn const double *DisplayerXlib::Getctm()

fn const double *DisplayerXlib::Getictm() Return a constant pointer to the inverse of the current transformation matrix.

Laxkit::DisplayerXlib::DisplayerXlib ( anXWindow nxw = NULL,
PanController pan = NULL 
)

Constructor, set everything to nothing or identity.

upperbound=1000, lowerbound=.00001, ctm/ictm=identity, fgcolor=white, bg=black


Member Function Documentation

LaxCompositeOp Laxkit::DisplayerXlib::BlendMode ( LaxCompositeOp  mode)
virtual

Set how to combine drawing elements to the target surface.

Currently, there are clear correspondences with only a coulpe Xlib modes, such as GXcopy, GXxor, and GXclear. All others map to GXcopy.

I leave it as an exercise for the reader to properly map all these to hopefully equivalent values: GXclear 0 GXand src AND dst GXandReverse src AND NOT dst GXcopy src GXandInverted NOT src AND dst GXnoop dst GXxor src XOR dst GXor src OR dst GXnor NOT src AND NOT dst GXequiv NOT src XOR dst GXinvert NOT dst GXorReverse src OR NOT dst GXcopyInverted NOT src GXorInverted NOT src OR dst GXnand NOT src OR NOT dst GXset 1

Implements Laxkit::Displayer.

References Laxkit::LAXOP_Clear, and Laxkit::LAXOP_Xor.

void Laxkit::DisplayerXlib::buildXPoints ( )
protectedvirtual

Rebuild xpoints to correspond to the current path, if any.

Todo:
shouldn't ignore multiple paths..

References Laxkit::bez_points(), closeopen(), Laxkit::NumStack< T >::e, Laxkit::NumStack< T >::flush(), Laxkit::NumStack< T >::n, Laxkit::NumStack< T >::push(), and realtoscreen().

int Laxkit::DisplayerXlib::ClearDrawable ( aDrawable drawable)
virtual

Free any data associated with drawable.

Return 1 for drawable not currently used, or 0 for cleared.

Implements Laxkit::Displayer.

References Laxkit::anXApp::app.

int Laxkit::DisplayerXlib::Clip ( Region  newregion,
int  append 
)
protectedvirtual

Calling code must XDestroyRegion(newregion).

References ClearClip(), Laxkit::Displayer::Maxx, Laxkit::Displayer::Maxy, Laxkit::Displayer::Minx, and Laxkit::Displayer::Miny.

Referenced by PopClip(), and PushClip().

int Laxkit::DisplayerXlib::Clip ( flatpoint p,
int  n,
int  append 
)
virtual

Copies the p array. If append!=0, then add the (closed) polyline to the clip area. If append==0, then replace any current clip area with the polygon.

All the points p are assumed to be screen coordinates.

Return 0 for success, nonzero for error.

Implements Laxkit::Displayer.

References ClearClip(), Laxkit::Displayer::Maxx, Laxkit::Displayer::Maxy, Laxkit::Displayer::Minx, and Laxkit::Displayer::Miny.

int Laxkit::DisplayerXlib::CreateSurface ( int  width,
int  height,
int  type = -1 
)
virtual

Create a fresh surface to perform drawing operations on.

Return 0 for successful creation.

Implements Laxkit::Displayer.

References Laxkit::anXApp::app, Laxkit::Displayer::Maxx, Laxkit::Displayer::Maxy, Laxkit::Displayer::Minx, and Laxkit::Displayer::Miny.

Referenced by ResizeSurface().

void Laxkit::DisplayerXlib::drawlines ( flatpoint points,
int  npoints,
char  closed,
char  fill 
)
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.

Implements Laxkit::Displayer.

References realtoscreen().

int Laxkit::DisplayerXlib::DrawReal ( )
virtual

Any subsequent calls are using real coordinates.

Returns old real_coordinates.

Reimplemented from Laxkit::Displayer.

int Laxkit::DisplayerXlib::DrawScreen ( )
virtual

Any subsequent calls are using screen coordinates.

Returns old real_coordinates.

Reimplemented from Laxkit::Displayer.

int Laxkit::DisplayerXlib::EndDrawing ( )
virtual

Sets gc,w,on all to 0.

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 DisplayerXlib drawing functions.. DisplayerXlib needs more work...

If xw==NULL, then call Updates(1);

Implements Laxkit::Displayer.

References Laxkit::Displayer::Updates().

void Laxkit::DisplayerXlib::FillAttributes ( int  fillstyle,
int  fillrule 
)
virtual

fillrule can be EvenOddRule or WindingRule. fillstyle can be FillSolid, FillTiled, FillStippled, or FillOpaqueStippled.

Implements Laxkit::Displayer.

int Laxkit::DisplayerXlib::font ( LaxFont nfont,
double  size = -1 
)
virtual

Return 0 for success, 1 for fail.

Implements Laxkit::Displayer.

References Laxkit::anXApp::app, Laxkit::anObject::dec_count(), and Laxkit::anObject::inc_count().

Referenced by font(), and ~DisplayerXlib().

int Laxkit::DisplayerXlib::font ( const char fontconfigpattern)
virtual

Return 0 for success, 1 for fail.

Implements Laxkit::Displayer.

int Laxkit::DisplayerXlib::font ( const char family,
const char style,
double  size 
)
virtual

Return 0 for success, 1 for fail.

Implements Laxkit::Displayer.

References Laxkit::anXApp::app, Laxkit::anObject::dec_count(), font(), and Laxkit::FontManager::MakeFont().

double Laxkit::DisplayerXlib::Getmag ( int  c = 0)
virtual

Return the current magnification, screen=Getmag*real.

If c!=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 rotated, they do not correspond necessarily to the screen horizontal or vertical magnification. For that, call GetVMag.

Reimplemented from Laxkit::Displayer.

References ctm.

LaxImage * Laxkit::DisplayerXlib::GetSurface ( )
virtual

Return a new LaxImage that is copied from the current buffer.

Returned image has count of 1.

Implements Laxkit::Displayer.

References Laxkit::Displayer::Maxx, Laxkit::Displayer::Maxy, Laxkit::Displayer::Minx, and Laxkit::Displayer::Miny.

double Laxkit::DisplayerXlib::GetVMag ( int  x,
int  y 
)
virtual

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.

Reimplemented from Laxkit::Displayer.

References screentoreal().

int Laxkit::DisplayerXlib::imageout ( LaxImage image,
double  x,
double  y,
double  w,
double  h 
)
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. Return 2 for image would be drawn smaller than a pixel, so it's not actually drawn.

Todo:
should be able to do partial drawing when an image is huge, and only a tiny portion of it actually should be rendered.

Implements Laxkit::Displayer.

References activeMask(), Laxkit::LaxImage::h(), Laxkit::LaxImlibImage::Image(), Laxkit::DoubleBBox::intersect(), Laxkit::Displayer::Maxx, Laxkit::Displayer::Maxy, Laxkit::Displayer::Minx, Laxkit::Displayer::Miny, realtoscreen(), and Laxkit::LaxImage::w().

void Laxkit::DisplayerXlib::LineAttributes ( double  width,
int  dash,
int  cap,
int  join 
)
virtual

Set the width, whether solid, line cap and join.

This currently uses Xlib's names which are as follows.

width is only in screen pixels for now. See LaxJoinStyle and LaxCapStyle for values for cap and join.

Todo:
should be able to set dash pattern somehow, and set line width based on current transform...

Implements Laxkit::Displayer.

void Laxkit::DisplayerXlib::lineto ( flatpoint  p)
virtual

If there was no previous point, then this is the same as a moveto(p).

Implements Laxkit::Displayer.

References Laxkit::NumStack< T >::e, Laxkit::NumStack< T >::n, and Laxkit::NumStack< T >::push().

void Laxkit::DisplayerXlib::Newangle ( double  angle,
int  dir = 0,
int  dec = 1 
)
virtual

Rotate around real origin so that the x axis has angle between it and the screen horizontal.

TODO: this could certainly be optimized..

Reimplemented from Laxkit::Displayer.

References angle2(), ctm, findictm(), rotate(), and Laxkit::Displayer::syncPanner().

Referenced by Rotate().

unsigned long Laxkit::DisplayerXlib::NewBG ( double  r,
double  g,
double  b 
)
virtual

Set new background color. Typically usage is NewFG(app->rgbcolor(.5,.8,0)).

Component range is [0..1.0].

Implements Laxkit::Displayer.

References Laxkit::rgbcolor().

unsigned long Laxkit::DisplayerXlib::NewFG ( double  r,
double  g,
double  b,
double  a = 1.0 
)
virtual

Set new foreground color. Typically usage is NewFG(app->rgbcolor(.5,.8,0,1.0)).

Component range is [0..1.0].

Implements Laxkit::Displayer.

References Laxkit::rgbcolor().

unsigned long Laxkit::DisplayerXlib::NewFG ( int  r,
int  g,
int  b,
int  a = 255 
)
virtual

Set new foreground. Typically usage is NewFG(app->rgbcolor(23,34,234)).

Component range is currently 0..255.... subject to change.

Implements Laxkit::Displayer.

References Laxkit::rgbcolor().

void Laxkit::DisplayerXlib::Newmag ( double  xs,
double  ys = -1 
)
virtual

Set the xscale and the yscale.

If ys<=0, then the y scale is set the same as the xscale.

Todo:
this could certainly be optimized.

Reimplemented from Laxkit::Displayer.

References ctm, findictm(), and Laxkit::Displayer::syncPanner().

flatpoint Laxkit::DisplayerXlib::realtoscreen ( flatpoint  p)
virtual

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
  

Implements Laxkit::Displayer.

References ctm.

Referenced by buildXPoints(), drawline(), drawlines(), drawpixel(), drawpoint(), imageout(), Rotate(), textout(), Zoom(), and Zoomr().

flatpoint Laxkit::DisplayerXlib::realtoscreen ( double  x,
double  y 
)
virtual

Convert real point (x,y) to screen coordinates.

  screen x= ax + cy + tx  –> screen = [x',y',1] = [x,y,1] * CTM  = real * CTM
  screen y= bx + dy + ty
  

Implements Laxkit::Displayer.

References ctm.

int Laxkit::DisplayerXlib::ResizeSurface ( int  width,
int  height 
)
virtual

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.

Implements Laxkit::Displayer.

References CreateSurface(), Laxkit::Displayer::Maxx, and Laxkit::Displayer::Maxy.

void Laxkit::DisplayerXlib::Rotate ( double  angle,
int  x,
int  y,
int  dec = 1 
)
virtual

Rotate by angle, about screen coordinate (x,y).

dec nonzero means angle is degrees, otherwise radians.

Reimplemented from Laxkit::Displayer.

References ctm, findictm(), Newangle(), realtoscreen(), screentoreal(), and Laxkit::Displayer::syncPanner().

int Laxkit::DisplayerXlib::StartDrawing ( aDrawable buffer)
virtual

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.

Implements Laxkit::Displayer.

References Laxkit::anXApp::app, Laxkit::Displayer::Maxx, Laxkit::Displayer::Maxy, Laxkit::Displayer::Minx, Laxkit::Displayer::Miny, and Laxkit::Displayer::Updates().

XftDraw * Laxkit::DisplayerXlib::textdraw ( Window  xlib_window)

Return the application's default Xft text drawing context.

Return a new one if none exists currently. Set to window if it does.

If window==None, then destroy the existing textxftdraw. This is necessary to do before the window is destroyed or else an X error pops up at strange times.

Referenced by textout_line().

double Laxkit::DisplayerXlib::textout_line ( double  x,
double  y,
const char str,
int  len = 0,
unsigned long  align = LAX_CENTER 
)
virtual

Returns distance advanced.

References Laxkit::anXApp::app, Laxkit::colorrgb(), and textdraw().

Referenced by textout().


Member Data Documentation

double Laxkit::DisplayerXlib::ctm[]
protected

Current Transformation Matrix.

This is a six valued array, see intro for discussion. This matrix is not dynamic like ctm. Is computed on the fly as necessary. Only the ctm is pushed and popped.

Referenced by findictm(), Getmag(), m(), Newangle(), Newmag(), NewTransform(), PopAxes(), PushAndNewTransform(), PushAxes(), realtoscreen(), Rotate(), ShiftReal(), ShiftScreen(), Zoom(), Zoomr(), and ~DisplayerXlib().

double Laxkit::DisplayerXlib::ictm[6]
protected

Inverse Current Transformation Matrix.

This is a six valued array, see intro for discussion.

Referenced by findictm(), screentoreal(), and ShiftScreen().


The documentation for this class was generated from the following files:

Mon Feb 17 2014 11:52:59, Laxkit