Laxkit
0.0.7.1
|
Class to deal with PatchData objects. More...
Public Types | |
enum | PatchDecorations { SHOW_Grid = (1<<0), SHOW_Points = (1<<1), SHOW_Edges = (1<<2), SHOW_Max = (1<<3) } |
Public Member Functions | |
PatchInterface (int nid, Laxkit::Displayer *ndp) | |
virtual Laxkit::ShortcutHandler * | GetShortcuts () |
virtual const char * | IconId () |
virtual const char * | Name () |
virtual const char * | whattype () |
virtual const char * | whatdatatype () |
virtual anInterface * | duplicate (anInterface *dup) |
Return duplicate of this. | |
virtual int | UseThisObject (ObjectContext *oc) |
virtual int | UseThis (Laxkit::anObject *newdata, unsigned int mask=0) |
virtual int | UseThis (int id, int ndata) |
virtual void | Clear (SomeData *d=NULL) |
Delete data, and flush curpoints. Make needtodraw=1. | |
virtual int | InterfaceOn () |
virtual int | InterfaceOff () |
Flush curpoints. | |
virtual ObjectContext * | Context () |
virtual int | LBDown (int x, int y, unsigned int state, int count, const Laxkit::LaxMouse *d) |
virtual int | LBUp (int x, int y, unsigned int state, const Laxkit::LaxMouse *d) |
virtual int | MouseMove (int x, int y, unsigned int state, const Laxkit::LaxMouse *d) |
virtual int | CharInput (unsigned int ch, const char *buffer, int len, unsigned int state, const Laxkit::LaxKeyboard *d) |
virtual int | KeyUp (unsigned int ch, unsigned int state, const Laxkit::LaxKeyboard *d) |
virtual void | drawpatch (int roff, int coff) |
Draw a grid over patch, lines every 1/griddivisions for s and t directions. | |
virtual void | drawpatches () |
Draw the whole patch. | |
virtual int | Refresh () |
virtual int | DrawData (Laxkit::anObject *ndata, Laxkit::anObject *a1=NULL, Laxkit::anObject *a2=NULL, int info=0) |
virtual PatchData * | newPatchData (double xx, double yy, double ww, double hh, int nr, int nc, unsigned int stle) |
Return a new local PatchData. | |
virtual void | deletedata () |
Delete data, and flush curpoints. | |
virtual int | scan (int x, int y) |
virtual int | SelectPoint (int c, unsigned int state) |
Public Member Functions inherited from LaxInterfaces::anInterface | |
anInterface () | |
This constructor assigns id=getUniqueNumber(). | |
anInterface (int nid) | |
Constructor to assign just the id, set other stuff to 0. | |
anInterface (int nid, Laxkit::Displayer *ndp) | |
anInterface (anInterface *nowner, int nid) | |
Constructor to assign owner and id. | |
anInterface (anInterface *nowner, int nid, Laxkit::Displayer *ndp) | |
virtual int | draws (const char *atype) |
Returns !strcmp(whatdatatype(),atype). | |
virtual void | Clear () |
Default just calls Clear(NULL). | |
virtual int | RemoveChild () |
If there is a child, do something to remove it. | |
virtual int | AddChild (LaxInterfaces::anInterface *ch, int absorbcount, int addbefore) |
virtual int | Needtodraw () |
Must return nonzero if the data needs to be drawn, that is to say Refresh must be called. | |
virtual int | Needtodraw (int n) |
virtual int | MBDown (int x, int y, unsigned int state, int count, const Laxkit::LaxMouse *d) |
virtual int | RBDown (int x, int y, unsigned int state, int count, const Laxkit::LaxMouse *d) |
virtual int | MBUp (int x, int y, unsigned int state, const Laxkit::LaxMouse *d) |
virtual int | RBUp (int x, int y, unsigned int state, const Laxkit::LaxMouse *d) |
virtual int | WheelUp (int x, int y, unsigned int state, int count, const Laxkit::LaxMouse *d) |
virtual int | WheelDown (int x, int y, unsigned int state, int count, const Laxkit::LaxMouse *d) |
virtual int | DeviceChange (const Laxkit::DeviceEventData *e) |
virtual int | Event (const Laxkit::EventData *e, const char *mes) |
Respond to events, particularly menu events from a menu created from ContextMenu(). | |
virtual void | ExposeChange (Laxkit::ScreenEventData *e) |
virtual void | ViewportResized () |
Called after the parent viewport gets resized. | |
virtual void | Mapped () |
Called after the parent viewport gets mapped (made visible). | |
virtual void | Unmapped () |
Called after the parent viewport gets mapped (made invisible, such as offscreen, not merely obscured). | |
virtual void | PostMessage (const char *message) |
If viewport, use that, else app->postmessage(). | |
virtual Laxkit::MenuInfo * | ContextMenu (int x, int y, int deviceid) |
Return a context sensitive menu for screen position (x,y). | |
virtual Laxkit::anXWindow * | CurrentWindow (Laxkit::anXWindow *ncur) |
Set the window the interface works on to ncur. Returns ncur. If ncur==NULL, then just return current viewport. | |
virtual void | Dp (Laxkit::Displayer *ndp) |
Set the dp to ndp, and update curwindow/viewport. | |
virtual int | DrawDataDp (Laxkit::Displayer *tdp, SomeData *tdata, Laxkit::anObject *a1=NULL, Laxkit::anObject *a2=NULL, int info=1) |
Use a different dp to draw data with. | |
virtual flatpoint | realtoscreen (flatpoint r) |
Do a little extra checking to find what point r should correspond to. | |
virtual flatpoint | screentoreal (int x, int y) |
Do a little extra checking to find what point (x,y) should correspond to. | |
virtual double | Getmag (int c=0) |
Do a little extra checking to find what the magnification is. | |
virtual double | GetVMag (int x, int y) |
Do a little extra checking to find what the magnification is. | |
virtual void | dump_out (FILE *f, int indent, int what, Laxkit::anObject *savecontext) |
Default settings saving is to output nothing. | |
virtual void | dump_in_atts (LaxFiles::Attribute *att, int flag, Laxkit::anObject *loadcontext) |
Placeholder for dumping in settings. | |
Public Member Functions inherited from LaxFiles::DumpUtility | |
virtual Attribute * | dump_out_atts (Attribute *att, int what, Laxkit::anObject *savecontext) |
Default is return NULL. what==0 means write out normal Attribute formatted things. | |
virtual void | dump_in (FILE *f, int indent, int what, Laxkit::anObject *loadcontext, Attribute **att) |
Read in a file segment as an Attribute, and pass parsing duties to dump_in_atts. | |
virtual | ~DumpUtility () |
Empty virtual destructor. |
Public Attributes | |
LineStyle | linestyle |
unsigned long | rimcolor |
unsigned long | handlecolor |
unsigned long | gridcolor |
int | xs |
int | ys |
int | rdiv |
int | cdiv |
unsigned long | controlcolor |
int | showdecs |
int | oldshowdecs |
char | whichcontrols |
int | recurse |
int | rendermode |
How to draw the overall patch. | |
PatchData * | data |
ObjectContext * | poc |
Public Attributes inherited from LaxInterfaces::anInterface | |
char * | name |
An instance name.. ***don't think this is used anywhere at the moment. | |
int | id |
Must be positive, other values are reserved for internal use. | |
unsigned long | style |
Style flags for the interface. Meaning depends on the interface. | |
int | interface_type |
What sort of interface this is. Default is INTERFACE_Tool. | |
Laxkit::anXApp * | app |
The application this interface works with. | |
Laxkit::anXWindow * | curwindow |
The window the interface currently works on. | |
anInterface * | owner |
The interface that owns this one. | |
anInterface * | child |
The child of this interface. See anInterface::owner. This is dec_counted in destructor. | |
int | primary |
Whether this is supposed to be a 'main' interface, or merely a helper. | |
int | needtodraw |
Whether the interface thinks it has to refresh. |
Protected Member Functions | |
void | getG (double *G, int roffset, int coffset, int isfory) |
virtual int | selectablePoint (int i) |
Return whether point c is ok to select. | |
virtual int | findNearHorizontal (flatpoint fp, double d, double *t_ret, int *i_ret) |
Return the row number corresponding to the first patch edge within d of fp. | |
virtual int | findNearVertical (flatpoint fp, double d, double *t_ret, int *i_ret) |
Return the column number corresponding to the first patch edge within d of fp. | |
virtual void | drawControlPoints () |
virtual void | drawControlPoint (int i) |
Draw a single point. This is for the hoverpoint, and is called from Refresh(). | |
virtual int | PerformAction (int action) |
Protected Attributes | |
double | movetransform [6] |
flatpoint * | movepts |
flatpoint | lbdown |
flatpoint * | cuth |
flatpoint * | cutv |
double | cutatct |
double | cutatrt |
int | overv |
int | overh |
int | overcv |
int | overch |
int | overstate |
Whether hovering over an edge is for adding (0) or cutting (1). | |
int | dragmode |
What to do on a button down-drag-up.. | |
int | hoverpoint |
int | bx |
int | by |
int | mx |
int | my |
int | constrain |
Laxkit::NumStack< int > | curpoints |
int | mousedragged |
Laxkit::ShortcutHandler * | sc |
Protected Attributes inherited from LaxInterfaces::anInterface | |
Laxkit::ButtonDownInfo | buttondown |
ViewportWindow * | viewport |
curwindow dynamically cast to ViewportWindow. Thus, it will be NULL if it is not a ViewportWindow. | |
Laxkit::Displayer * | dp |
The Displayer used by the controlling window. |
Class to deal with PatchData objects.
This class allows manipulation of cubic tensor bezier patches. A patch here starts as a square, and it can be subdivided, and the points grouped and moved around easily. That is, easily enough as tensor product patches go, anyway.
*** add warping controls, such as control how to warp to circle, 3x3 matrix warp. maybe add some kind of generic TransformInterface to allow skewing,flipping of selected points
*** This does not implement the free form patch setup found in Postscript. that functionality might go in a separate class, as the needs are a little too different perhaps.
|
virtual |
'b' toggle which control points can be shifted 'B' opposite of 'b' 'j' toggle smooth editing mode (j for jagged) 'a' select all points, or deselect all if any are selected 'y' constrain to y changes, or release the constraint 'x' constrain to x changes, or release the constraint 'R' increase how many rows to divide each row into ^'R' decrease how many rows to divide each row into 'r' subdivide rows 'c' subdivide columns 'C' increase how many columns to divide each column into ^'C' decrease how many columns to divide each column into 's' subdivide rows and columns 'z' reset to rectangular (z for zap) 'd' toggle decorations 'H' select all points in rows of current points 'V' select all points in columns of current points 'h' select points adjacent horizontally to current points 'v' select points adjacent vertically to current points 'm' for debugging, popup a showmat '1' select corners: 0,0 0,3 3,0 3,3 '2' select center controls: 1,1 1,2 2,1 2,2 '3' select edge controls: 0,1 0,2 1,0 2,0 1,3 2,3 3,1 3,2 '4' select top and bottom controls: 1,0 2,0 1,3 2,3 '5' select left and right controls: 0,1 0,2 3,1 3,2 '8' select a 3x3 group of points around each current point 'i' reset patch inside points to Coons like values 'o' increment how much to recurse 'O' decrement how much to recurse
*** l/r/u/d to shift selected points: plain-move rolls curpoints, shift-move adds to curpoints, control-move rolls without wraparound
whichcontrols or data->controls?
Reimplemented from LaxInterfaces::anInterface.
References Laxkit::ShortcutHandler::FindActionNumber(), Laxkit::NumStack< T >::flush(), MouseMove(), Laxkit::NumStack< T >::n, and LaxInterfaces::anInterface::needtodraw.
|
virtual |
Delete data, and flush curpoints. Make needtodraw=1.
*** this might not be necessary, default Clear() calls deletedata() which flushes...
Implements LaxInterfaces::anInterface.
References deletedata(), Laxkit::NumStack< T >::flush(), and LaxInterfaces::anInterface::needtodraw.
|
protectedvirtual |
References LaxInterfaces::anInterface::dp, Laxkit::Displayer::drawarrow(), Laxkit::Displayer::drawpoint(), Laxkit::NumStack< T >::e, Laxkit::NumStack< T >::n, Laxkit::Displayer::NewFG(), and selectablePoint().
Referenced by Refresh().
Draw a grid over patch, lines every 1/griddivisions for s and t directions.
roff,coff is which patch, point start is == roff*3
Reimplemented in LaxInterfaces::ImagePatchInterface, and LaxInterfaces::ColorPatchInterface.
References LaxInterfaces::B, LaxInterfaces::dot(), LaxInterfaces::anInterface::dp, Laxkit::Displayer::drawlines(), Laxkit::Displayer::DrawReal(), LaxInterfaces::PatchData::getGt(), Laxkit::Displayer::LineAttributes(), LaxInterfaces::m_times_m(), LaxInterfaces::m_times_v(), and Laxkit::Displayer::NewFG().
Referenced by drawpatches().
|
virtual |
Draw the whole patch.
This calls drawpatch() for each subpatch. Called from Refresh().
References drawpatch().
Referenced by Refresh().
|
protectedvirtual |
Return the column number corresponding to the first patch edge within d of fp.
This goes by vertex column, so for data->xsize==4, there are columns 0 and 1.
References Laxkit::bez_near_point(), and Laxkit::DoubleBBox::clear().
Referenced by MouseMove().
|
virtual |
Reimplemented from LaxInterfaces::anInterface.
References angle(), LaxInterfaces::PatchData::bezCrossSection(), dragmode, Laxkit::NumStack< T >::e, LaxInterfaces::PatchData::FindBBox(), findNearHorizontal(), findNearVertical(), LaxInterfaces::anInterface::Getmag(), LaxInterfaces::PatchData::inSubPatch(), LaxInterfaces::PatchData::InterpolateControls(), Laxkit::ButtonDownInfo::isdown(), Laxkit::NumStack< T >::n, LaxInterfaces::anInterface::needtodraw, norm(), overstate, rotate(), scan(), LaxInterfaces::anInterface::screentoreal(), selectablePoint(), Laxkit::transform_copy(), Laxkit::transform_invert(), Laxkit::transform_mult(), Laxkit::transform_point(), Laxkit::transform_point_inverse(), Laxkit::transform_rotate(), and Laxkit::transform_set().
Referenced by CharInput().
|
virtual |
Return a new local PatchData.
Usually, subclasses would redefine this, which gets called from LBDown(). Returns object with count of 1.
Reimplemented in LaxInterfaces::EngraverFillInterface, LaxInterfaces::ColorPatchInterface, and LaxInterfaces::ImagePatchInterface.
References LaxInterfaces::PatchData::FindBBox(), LaxInterfaces::SomeDataFactory::newObject(), LaxInterfaces::PatchData::Set(), and LaxInterfaces::somedatafactory.
|
virtual |
Draw in grid form. Calls drawpatch(r,c) for each subpatch. Derived classes need not redo Refresh. They can just redo drawpatch().
Reimplemented from LaxInterfaces::anInterface.
References LaxInterfaces::PatchData::bezAtEdge(), LaxInterfaces::anInterface::dp, dragmode, Laxkit::Displayer::drawbez(), drawControlPoint(), drawControlPoints(), Laxkit::Displayer::drawline(), drawpatches(), LaxInterfaces::SomeData::GetPreview(), Laxkit::Displayer::imageout(), Laxkit::Displayer::LineAttributes(), LaxInterfaces::anInterface::needtodraw, Laxkit::Displayer::NewFG(), overstate, rendermode, Laxkit::rgbcolor(), Laxkit::Displayer::screentoreal(), showdecs, and Laxkit::transform_point().
*** need better scanning, to start at point after currently selected // no pick wild,start,end, picks closest within a distance // *** only checks points, no online jazz
References LaxInterfaces::anInterface::dp, Laxkit::Displayer::Getmag(), LaxInterfaces::anInterface::screentoreal(), and Laxkit::transform_point().
Referenced by MouseMove().
Return whether point c is ok to select.
For instance, in a Coons patch, the inner controls for each subsection are not selectable.
Referenced by drawControlPoints(), and MouseMove().
Returns num of points selected.
References Laxkit::NumStack< T >::e, Laxkit::NumStack< T >::flush(), Laxkit::NumStack< T >::n, LaxInterfaces::anInterface::needtodraw, Laxkit::NumStack< T >::pop(), and Laxkit::NumStack< T >::push().
|
virtual |
Takes a PatchData, or LineStyle.
Reimplemented from LaxInterfaces::anInterface.
References LaxInterfaces::anInterface::needtodraw.
Referenced by LaxInterfaces::ImagePatchInterface::UseThis(), and LaxInterfaces::EngraverFillInterface::UseThis().
Takes magic number: id==2 is xs, and id==3 is ys.
Reimplemented from LaxInterfaces::anInterface.
Reimplemented in LaxInterfaces::EngraverFillInterface, and LaxInterfaces::ImagePatchInterface.
References LaxInterfaces::anInterface::app, and Laxkit::anXApp::postmessage().
|
protected |
What to do on a button down-drag-up..
If dragmode==1, then the mouse was clicked down on an edge, and moving the mouse will show where a new edge will appear, and will result in a new row or column being added to the patch.
If dragmode==2, then the mouse was clicked on an edge, but the intention is to move the existing edge without creating a new column or row.
Referenced by MouseMove(), and Refresh().
|
protected |
Whether hovering over an edge is for adding (0) or cutting (1).
See overh and overv.
Referenced by MouseMove(), and Refresh().
int LaxInterfaces::PatchInterface::rendermode |
How to draw the overall patch.
In PatchInterface, you can only draw grid lines, but in subclasses like ColorPatchInterface and ImagePatchInterface, you can draw grid lines only, or the color data instead.
rendermode==0 means draw only the basic grid lines. rendermode==1 means use data->preview for the patch, and draw the grid if no preview available. rendermode==2 means use drawpatches(), which usually would call drawpatch() once for each subpatch in a patch. This would be used when you don't want to render previews, but instead draw the patch over each time. rendermode==3 means don't actually draw anything but control stuff.
Referenced by LaxInterfaces::ColorPatchInterface::drawpatch(), LaxInterfaces::ImagePatchInterface::drawpatch(), Refresh(), LaxInterfaces::ImagePatchInterface::UseThis(), and LaxInterfaces::EngraverFillInterface::UseThis().
int LaxInterfaces::PatchInterface::showdecs |
Show points, grid, and/or edges.
Referenced by InterfaceOff(), and Refresh().