Laxkit
0.0.7.1
|
Handles RectData or works directly on the matrix of any SomeData. More...
Public Member Functions | |
RectInterface (int nid, Laxkit::Displayer *ndp) | |
virtual Laxkit::ShortcutHandler * | GetShortcuts () |
virtual Laxkit::MenuInfo * | ContextMenu (int x, int y, int deviceid) |
virtual const char * | IconId () |
virtual const char * | Name () |
virtual const char * | whattype () |
virtual const char * | whatdatatype () |
virtual anInterface * | duplicate (anInterface *dup) |
virtual int | InterfaceOn () |
virtual int | InterfaceOff () |
virtual int | LBDown (int x, int y, unsigned int state, int count, const Laxkit::LaxMouse *d) |
virtual int | FakeLBDown (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 int | Refresh () |
virtual int | DrawData (Laxkit::anObject *ndata, Laxkit::anObject *a1=NULL, Laxkit::anObject *a2=NULL, int info=0) |
virtual int | UseThis (Laxkit::anObject *newdata, unsigned int) |
virtual void | Clear (SomeData *d=NULL) |
virtual int | AlternateScan (flatpoint sp, flatpoint p, double xmag, double ymag, double onepix) |
virtual int | scan (int x, int y) |
Return the point clicked on. RP_Move for on data, but not point, RP_None for nothing. | |
virtual void | deletedata () |
virtual flatpoint | getpoint (int c, int trans) |
virtual void | GetOuterRect (Laxkit::DoubleBBox *box, double *mm) |
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 int | UseThis (int id, int ndata) |
Return 1 if the id/ndata is used, otherwise zero. | |
virtual int | UseThisObject (ObjectContext *oc) |
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 ObjectContext * | Context () |
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 | |
int | maxtouchlen |
The maximum screen length in pixels that a transform handle is allowed to have. | |
int | extrapoints |
int | griddivisions |
unsigned int | style |
unsigned long | controlcolor |
int | creationstyle |
int | createfrompoint |
int | showdecs |
SomeData * | somedata |
RectData * | data |
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. | |
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 | |
virtual void | syncToData () |
Set the somedata's axes and origin from xdir, etc. | |
virtual void | syncFromData (int first) |
Set up xaxislen, yaxislen, xdir, and ydir from somedata. | |
virtual const char * | hoverMessage (int p) |
Return a string of a message for hovering over type p. | |
virtual void | Flip (int type) |
Flip the rectangle. type must be one of RP_Flip_Go, RP_Flip_H, or RP_Flip_V. | |
virtual void | Rotate (double angle) |
virtual int | PerformAction (int action) |
virtual int | GetMode () |
Protected Attributes | |
int | lastpoint |
flatpoint | createp |
flatpoint | createx |
flatpoint | createy |
flatpoint | center1 |
flatpoint | center2 |
flatpoint | shearpoint |
flatpoint | leftp |
flatpoint | flip1 |
flatpoint | flip2 |
double | rotatestep |
int | hover |
int | mousetarget |
int | shiftmode |
flatpoint | hoverpoint |
double | rw |
double | rh |
flatpoint | origin |
flatpoint | xdir |
flatpoint | ydir |
double | xaxislen |
double | yaxislen |
char | dragmode |
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. |
Handles RectData or works directly on the matrix of any SomeData.
This is a very souped up version of select by rectangle, you can rotate, scale, adjust by edges, etc. Included is a 3-point transform, wherein you can select an arbitrary center of scaling or rotation, and click and drag so the object is scaled and rotated to keep up with the dragging. Also, you can define another anchor point, and drag a third point which shears the object, with the first two anchor points staying in the same spot.
The idea here is for this class to be the base class of a potential selection rectangle interface, and also for an object transform modification interface. For instance, EllipseInterface is built using a RectInterface to trace out a rectangle, inside of which the ellipse is placed.
Also, ObjectInterface is subclassed to use a dotted rectangle for selecting objects in a ViewportWindow.
This interface will modify only the matrix of its data and not the bounds, unless it is a RectData, in which case the attributes of that are fair game.
********* there appears to be a bit of memory corruption somewhere. frequently, data->griddivisions gets a crazy value...
*** update docs here!
*** differentiate move preserve aspect, and move with aspect==1 (as square) ***draw only whats necessary ***general debug, ISSQUARE *** a style to allow movement only, not resize, except on cntl??? VISIBLECENTER still allows a center for rotations if center is on a control point, be able to sequentially select point(s) beneath
*** should probably have a style where you just section off a plain, non rotated rectangle with no control points indicated. like for cropping
*** need mode to distinguish between modifying the min/max bounds, and modifying the matrix. When the matrix is adjusted so that w==0 or h==0, there are special problems to check for!! causes matrix to be degenerate...
Note that somedata (a SomeData) holds the basic object, and if the object happens to be a RectData, then data is the RectData cast of somedata. When new data is created internally, the viewport is not notified to insert this new data, unlike in most of the other interfaces. This makes it easier for other classes to use this class to trace out areas.
|
virtual |
Dec count data, setting data and somedata to NULL.
References Laxkit::anObject::dec_count().
|
virtual |
! Tries to set curpoint and flags for redrawing. Returns the curpoint. ! Valid points are 1 to npoints.
Used when transferring control to a child RectInterface, and default to the left button being down, and RP_Move. If !somedata, nothing is done.
References Laxkit::ButtonDownInfo::down(), and LaxInterfaces::anInterface::needtodraw.
|
protectedvirtual |
Default is return 0. This is so you don't have to redefine CharInput when implementing more complicated interface modes. You just add the shortcuts, and it works.
|
virtual |
Return a rectangle and transform rotated, translated, and sheared in screen coordinates. The x and y axes are of unit length, thus it visually overlaps the actual data, but does NOT correspond to the data's actual transform.
The rectangle is oriented such that the first and second points are the "top most" edge.
References LaxInterfaces::anInterface::dp, and Laxkit::Displayer::realtoscreen().
If (trans) then transform the data space point by somedata->m().
x+—- > y 1 8 7
References Laxkit::transform_point().
Referenced by LaxInterfaces::EllipseInterface::getpoint(), MouseMove(), and Refresh().
|
virtual |
Shift/noshift toggles end/start point
Reimplemented from LaxInterfaces::anInterface.
References Laxkit::ButtonDownInfo::any(), and LaxInterfaces::anInterface::needtodraw.
|
virtual |
If style&RECT_OBJECT_SHUNT, then do not transfer control to another interface if clicking on another object. This allows subclassed object interfaces to stay in charge.
Get rid of old data if not clicking in it.
Reimplemented from LaxInterfaces::anInterface.
Reimplemented in LaxInterfaces::ObjectInterface.
References Laxkit::ButtonDownInfo::any(), LaxInterfaces::RectData::centercenter(), LaxInterfaces::ViewportWindow::ChangeContext(), LaxInterfaces::ViewportWindow::ChangeObject(), deletedata(), Laxkit::ButtonDownInfo::down(), LaxInterfaces::anInterface::dp, LaxInterfaces::ViewportWindow::FindObject(), Laxkit::anObject::inc_count(), LaxInterfaces::anInterface::needtodraw, LaxInterfaces::SomeDataFactory::newObject(), LaxInterfaces::SomeData::pointin(), LaxInterfaces::anInterface::primary, scan(), Laxkit::Displayer::screentoreal(), LaxInterfaces::anInterface::screentoreal(), Laxkit::DoubleBBox::setbounds(), LaxInterfaces::somedatafactory, syncFromData(), Laxkit::transform_point_inverse(), Laxkit::ButtonDownInfo::up(), and LaxInterfaces::anInterface::viewport.
|
virtual |
move drags point, control-move rotates and shears
2 9 6 | 3 4 5 v
Reimplemented from LaxInterfaces::anInterface.
Reimplemented in LaxInterfaces::ObjectInterface.
References Laxkit::ButtonDownInfo::any(), LaxInterfaces::RectData::centercenter(), LaxInterfaces::anInterface::dp, Laxkit::ButtonDownInfo::getcurrent(), Laxkit::ButtonDownInfo::getextrainfo(), Laxkit::ButtonDownInfo::getinitial(), getpoint(), hoverMessage(), Laxkit::ButtonDownInfo::isdown(), Laxkit::ButtonDownInfo::move(), Laxkit::ButtonDownInfo::moveinfo(), LaxInterfaces::anInterface::needtodraw, norm(), LaxInterfaces::anInterface::PostMessage(), rotate(), scan(), Laxkit::Displayer::screentoreal(), syncFromData(), Laxkit::transform_from_basis(), Laxkit::transform_invert(), Laxkit::transform_mult(), Laxkit::transform_point(), Laxkit::transform_point_inverse(), transpose(), and Laxkit::ButtonDownInfo::whichdown().
Referenced by LaxInterfaces::EllipseInterface::MouseMove().
|
virtual |
Default refresh is to draw a dashed line around the bounding box. If showdecs, then also draw the common stretchy handles.
Reimplemented from LaxInterfaces::anInterface.
Reimplemented in LaxInterfaces::ObjectInterface.
References LaxInterfaces::anInterface::dp, Laxkit::Displayer::drawarrow(), Laxkit::Displayer::drawbez(), Laxkit::Displayer::drawline(), Laxkit::Displayer::drawlines(), Laxkit::Displayer::drawpoint(), Laxkit::Displayer::DrawReal(), Laxkit::Displayer::DrawScreen(), Laxkit::Displayer::drawthing(), getpoint(), Laxkit::Displayer::LineAttributes(), maxtouchlen, LaxInterfaces::anInterface::needtodraw, Laxkit::Displayer::NewFG(), norm(), Laxkit::Displayer::PopAxes(), Laxkit::Displayer::PushAndNewTransform(), Laxkit::Displayer::realtoscreen(), Laxkit::THING_Circle_Plus, and transpose().
Return the point clicked on. RP_Move for on data, but not point, RP_None for nothing.
If clicked in the data, and extra points only has center1, then return RP_Center2, and for when there is center1 and center2, return RP_Shearpoint. This allows creation of temporary drag points, dependent on which of the center point, scale-drag point or shear points are defined.
References AlternateScan(), distance(), LaxInterfaces::anInterface::dp, maxtouchlen, norm(), norm2(), Laxkit::Displayer::realtoscreen(), Laxkit::Displayer::screentoreal(), Laxkit::transform_point(), and Laxkit::transform_point_inverse().
Referenced by LBDown(), MouseMove(), and LaxInterfaces::EllipseInterface::scan().
|
protectedvirtual |
Set up xaxislen, yaxislen, xdir, and ydir from somedata.
If first==1 then the data is newly installed. Otherwise, this is called from an LBDown, and compensates for any changes made from outside the interface (which are assumed to not have made the transform invalid *** maybe do that check anyway?).
These variables are used to help maintain orientations when using the transform handles. For instance, when scaling along an egde, you can flip the whole data around, making the somedata potentially pass through a zero width state, which would destroy all orientation data.
References norm(), and transpose().
Referenced by Flip(), LBDown(), MouseMove(), and UseThis().
|
virtual |
This accepts RectData OR just any SomeData. If it is a SomeData but not a rectdata, then data will be NULL, but somedata will not be NULL.
Reimplemented from LaxInterfaces::anInterface.
References deletedata(), Laxkit::anObject::inc_count(), LaxInterfaces::anInterface::needtodraw, and syncFromData().
Referenced by LaxInterfaces::EllipseInterface::EllipseInterface().
|
protected |
0 means normal. dragmode&1 means do not show the little arrow handles while dragging.
This variable can be used by subclasses to signal that dragging is to be used for creating or adding to a selection, for instance.