Laxkit
0.0.7.1
|
A PanController that uses doubles as a base. More...
Public Member Functions | |
DoublePanner (anXWindow *w=NULL, PanController *pan=NULL, char npanislocal=0) | |
Constructor, set everything to nothing or identity. | |
~DoublePanner () | |
Destructor, delete ctm. | |
virtual flatpoint | realtoscreen (double x, double y) |
Convert real point (x,y) to screen coordinates. | |
virtual flatpoint | realtoscreen (flatpoint p) |
Convert real point p 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 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 DoublePanner settings. | |
virtual char | onscreen (int x, int y) |
Return whether screen coordinate (x,y) is within (Minx..Maxx,Miny..Maxy). | |
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 | 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 int | NewTransform (double *d) |
Set the ctm to these 6 numbers. | |
virtual int | NewTransform (double a, double b, double c, double d, double x0, double y0) |
Make the transform correspond to the values. | |
virtual void | PushAndNewTransform (double *m) |
Push axes, and multiply ctm by a new transform.**** implement!! | |
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 | 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 | 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) | |
virtual void | SetView (double minx, double maxx, double miny, double maxy) |
Set the view area to these real bounds. | |
virtual int | RealSpace (double minx, double maxx, double miny, double maxy) |
Set the workspace bounds, return nonzero if successful. | |
virtual void | RealSpace (double *minx, double *maxx, double *miny, double *maxy) |
Get the workspace bounds. | |
virtual void | getTransformedSpace (long *minx, long *maxx, long *miny, long *maxy) |
Find the mins and maxes of the transformed workspace. | |
virtual void | WrapWindow (anXWindow *nw) |
Set the viewable portion of the displayer to correspond with the window's win_w and win_h. | |
Public Member Functions inherited from Laxkit::PanController | |
PanController () | |
Default constructor, sets minsel to 1, maxsel to 1000000, and style to PANC_ELEMENT_IS_PERCENT|PANC_PAGE_IS_PERCENT. | |
PanController (const PanController &pan) | |
Copy constructor. Does not copy tellstack. | |
PanController & | operator= (PanController &pan) |
Assignment operator does NOT copy the tellstack. Leaves tellstack as is. | |
PanController (long xmin, long xmax, long xstart, long xend, long ymin, long ymax, long ystart, long yend, int w, int h, unsigned long panstyle=PANC_ELEMENT_IS_PERCENT|PANC_PAGE_IS_PERCENT) | |
Constructor. | |
virtual | ~PanController () |
Destructor, turns off the panner in any PanUser in tellstack. | |
virtual long | SetPageSize (int which, long nps) |
Set so that end-start+1==nps. Returns new actual end-start+1;. | |
virtual long | GetPageSize (int which) |
Return end[which]-start[which]+1;. | |
virtual double | GetMagToBox (int which, int boxwidth, long *wholestartret, long *wholeendret) |
Get the horizontal (which==1) or vertical(=2) magnification of the box to the screen (screen=Getmag*real) | |
virtual double | GetMagToWhole (int which, int trackwidth, long *boxstartret, long *boxendret) |
Get the horizontal (which==1) or vertical(=2) magnification of the whole space to the screen (screen=Getmag*real) | |
virtual void | SetSelBounds (int which, long small, long big) |
Set the minimum selection size and maximum selection size. | |
virtual void | SetPixelAspect (double npixaspect=1.0) |
Set the level of difference between x and y zoom. | |
virtual double | findpixelaspect () |
Compute the new pixelaspect based on other info..... | |
virtual void | SetBoxAspect (int w, int h) |
Set the preferred dimensions of a target window. | |
virtual int | SetWholebox (long xmin, long xmax, long ymin, long ymax) |
Set both the dimensions of the workspace, preserving proportionally the selbox. | |
virtual int | SetStuff (int which, long nmin, long nmax, long nps, long nes, long posstart, long posend) |
Set the metrics of the space of one of the dimensions: 1==x, 2==y. | |
virtual int | SetSize (int which, long nmin, long nmax, long nps) |
Set the min/max, and adjust start,end based on nps. | |
virtual long | GetCurPos (int which, long *curpos=NULL, long *curposend=NULL) |
Return the start of x (which==1) or y (which==2) dimension. | |
virtual long | SetCurPos (int which, long pos) |
Set the start. Shortcut for calling Shift(pos-start). | |
virtual long | SetCurPos (int which, long poss, long pose) |
Set the start and the end. | |
virtual int | validateSelbox (int which=3) |
Make sure the selbox is completely in wholebox or vice versa, as necessary. | |
virtual int | adjustSelbox (int which=2, char validatetoo=1) |
Reconfigure the selbox based on boxaspect and pixelaspect. | |
virtual int | Center (int which=3) |
Make the whole and sel centers coincide. 1=x, 2=y, 0=neither, other=both. | |
virtual long | Shift (int which, long d, long wholelen=0, long boxlen=0) |
Shift the selbox x or y (if which==1 or 2) sel box by d units coords where whole maps to max-min+1. | |
virtual int | ShiftEnd (int which, long d, int center=0, long wholelen=0, long boxlen=0) |
Shift the screen sel box end by de units. wholelen maps to whole space (max-min+1). | |
virtual int | ShiftStart (int which, long ds, int center=0, long wholelen=0, long boxlen=0) |
Shift the screen sel box start by de units. wholelen maps to whole space (max-min+1). | |
virtual long | OneUp (int which) |
Move selbox one element size in the negative direction. | |
virtual long | OneDown (int which) |
Move selbox one element size in the positive direction. | |
virtual long | PageUp (int which, int numpages=1) |
Move selbox one page size in the negative direction. | |
virtual long | PageDown (int which, int numpages=1) |
Move selbox one page size in the positive direction. | |
virtual void | sendMessages () |
Send messages to all who want to know what's what with the pan. | |
virtual void | tell (anXWindow *win) |
Push win onto the stack of windows to notify of changes. | |
virtual void | tellPop (anXWindow *win=NULL) |
Pop win from the tellstack. If win==NULL, then flush the tellstack. | |
virtual void | dontTell (anXWindow *win) |
Exhempt win from getting messages sent to it, until dontTell(NULL) or dontTell(someotherwindow) is called. | |
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 | |
double | upperbound |
The maximum screen length of an axis and other items. | |
double | lowerbound |
The minimum screen length of an axis and other items. | |
Public Attributes inherited from Laxkit::PanController | |
anXWindow * | donttell |
unsigned int | pan_style |
Style of the controller. | |
int | sendstatus |
long | minsel [2] |
The minimum allowable selection which == end-start+1. | |
long | maxsel [2] |
The maximum allowable selection which == end-start+1. | |
long | min [2] |
The minimum coordinate of the space (min[0],min[1]). | |
long | max [2] |
The maximum coordinate of the space (max[0],max[1]). | |
long | start [2] |
The minimum coordinate of the selection box (start[0],start[1]). | |
long | end [2] |
The maximum coordinate of the selection box (end[0],end[1]). | |
long | pagesize [2] |
The pagesize used when calling PageUp/Down. | |
long | elementsize [2] |
The element used when calling OneUp/Down. | |
int | boxaspect [2] |
Basically the aspect of the window corresponding to the selection box. | |
double | pixelaspect |
The relative scaling between x and y: (pixel width/pixel height). | |
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 | |
double * | ctm |
Current Transformation Matrix. | |
double | ictm [6] |
Inverse Current Transformation Matrix. | |
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). | |
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. | |
PtrStack< double > | axesstack |
The stack of axes. See PushAxes() and PopAxes(). | |
Protected Attributes inherited from Laxkit::PanController | |
PtrStack< anXWindow > | tellstack |
Stack of windows to notify when settings change. | |
Protected Attributes inherited from Laxkit::anObject | |
int | _count |
The reference count of the object. |
A PanController that uses doubles as a base.
**** Please note that this class is totally unusable currently.
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.
*** have to coordinate panner->minsel/maxsel and upperbound/lowerbound.
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.
Note that in libart, they are presented basically as the transpose of the above, but the elements of the 6 value array mean essentially the same as both systems. In the Cairo library, cairo_matrix_t={ double xx,xy, yx,yy, x0,y0 } corresponds basically to [xx yx xy yy x0 y0].
Laxkit::DoublePanner::DoublePanner | ( | anXWindow * | w = NULL , |
PanController * | pan = NULL , |
||
char | npanislocal = 0 |
||
) |
Constructor, set everything to nothing or identity.
upperbound=1000, lowerbound=.00001, ctm/ictm=identity, Set Minx=Min=0, Maxx=w,Maxy=h
References Laxkit::PanController::boxaspect, ctm, ictm, lowerbound, Maxx, Maxy, Minx, Miny, Laxkit::PanController::pixelaspect, Laxkit::PanController::SetSelBounds(), spacemaxx, spacemaxy, spaceminx, spaceminy, and upperbound.
|
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. A gap of about 5% is placed around the bounds.
****** muts implement this!!!
References CenterPoint(), Maxx, Minx, Newmag(), realtoscreen(), and syncPanner().
|
virtual |
Make the center of Minx,Maxx... correspond to the real origin.
Min/Max are screen coordinates, so ctm[4],y is screen position of real origin
References ctm, ictm, Maxx, Maxy, Minx, Miny, syncPanner(), and Laxkit::transform_invert().
|
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.
References ctm.
|
virtual |
Find the mins and maxes of the transformed workspace.
It is ok to have some of the pointers NULL.
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.
References screentoreal().
Rotate around real origin so that the x axis has angle between it and the screen horizontal.
TODO: this could certainly be optimized..
References angle2(), ctm, ictm, rotate(), syncPanner(), and Laxkit::transform_invert().
Referenced by Rotate().
|
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.
References ctm, ictm, syncPanner(), and Laxkit::transform_invert().
Referenced by Center().
Push axes, and multiply ctm by a new basis, p,x,y are all in real units.
*** implement!! ***
References NewAxis(), and PushAxes().
|
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
References ctm.
Rotate by angle, about screen coordinate (x,y).
dec nonzero means angle is degrees, otherwise radians.
References ctm, ictm, Newangle(), realtoscreen(), screentoreal(), syncPanner(), and Laxkit::transform_invert().
|
virtual |
Set the view area to these real bounds.
These bounds will fit over the transformed workspace, and are to be in screen coordinates. That is, after a workspace is transformed into screen coordinates, the new coordinates are called transformed workspace coordinates. This is relevant since a workspace that is rotated takes up more in screen extent than an unrotated one.
Min/Maxx/y will not be changed, but afterwards they will correspond to these bounds. This is essentially a more complicated form of zooming.
*** this needs LOTS o work, right now just shifts (minx,miny) to correspond to (Minx,Miny) .. must be sure to preserve axes aspect
References Minx, Miny, realtoscreen(), and ShiftScreen().
|
virtual |
Using the settings in the panner, try to set the DoublePanner settings.
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 does not change its values, but the panner selbox has. However, the displayer "selbox" in Minx,Maxx..
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.
This function is not called from within the DoublePanner. A holding window (such as ViewportWindow) would call it upon receipt of a "pan change" **** but must ensure it is correct time!!
References ctm, Laxkit::dumpctm(), ictm, Maxx, Maxy, Minx, Miny, screentoreal(), syncPanner(), and Laxkit::transform_invert().
|
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.
References getTransformedSpace(), lowerbound, Maxx, Maxy, Minx, Miny, Laxkit::PanController::SetCurPos(), Laxkit::PanController::SetWholebox(), and upperbound.
Referenced by Center(), CenterReal(), Newangle(), Newmag(), NewTransform(), RealSpace(), Rotate(), ShiftReal(), ShiftScreen(), syncFromPanner(), WrapWindow(), Zoom(), and Zoomr().
*** 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.
|
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. 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.
*** this does not reassign dpy,gc,w, etc. That is done in StartDrawing. seems silly to wrap to this window, but not make all the other properties correspond to nw. needs more thought here.
References ctm, Maxx, Maxy, Minx, Miny, spacemaxx, spacemaxy, spaceminx, spaceminy, and syncPanner().
|
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 CenterReal(), DoublePanner(), GetMag(), Newangle(), NewAxis(), Newmag(), NewTransform(), PopAxes(), PushAndNewTransform(), PushAxes(), realtoscreen(), Rotate(), ShiftReal(), ShiftScreen(), syncFromPanner(), WrapWindow(), Zoom(), Zoomr(), and ~DoublePanner().
|
protected |
Inverse Current Transformation Matrix.
This is a six valued array, see intro for discussion.
Referenced by CenterReal(), DoublePanner(), Newangle(), NewAxis(), Newmag(), NewTransform(), PopAxes(), PushAndNewTransform(), PushAxes(), Rotate(), screentoreal(), ShiftReal(), ShiftScreen(), syncFromPanner(), Zoom(), and Zoomr().