Laxkit  0.0.7.1
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes
LaxInterfaces::RectInterface Class Reference

Handles RectData or works directly on the matrix of any SomeData. More...

Inheritance diagram for LaxInterfaces::RectInterface:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 RectInterface (int nid, Laxkit::Displayer *ndp)
virtual Laxkit::ShortcutHandlerGetShortcuts ()
virtual Laxkit::MenuInfoContextMenu (int x, int y, int deviceid)
virtual const charIconId ()
virtual const charName ()
virtual const charwhattype ()
virtual const charwhatdatatype ()
virtual anInterfaceduplicate (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::anXWindowCurrentWindow (Laxkit::anXWindow *ncur)
 Set the window the interface works on to ncur. Returns ncur. If ncur==NULL, then just return current viewport.
virtual ObjectContextContext ()
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 Attributedump_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
SomeDatasomedata
RectDatadata
- Public Attributes inherited from LaxInterfaces::anInterface
charname
 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::anXAppapp
 The application this interface works with.
Laxkit::anXWindowcurwindow
 The window the interface currently works on.
anInterfaceowner
 The interface that owns this one.
anInterfacechild
 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 charhoverMessage (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::ShortcutHandlersc
- Protected Attributes inherited from LaxInterfaces::anInterface
Laxkit::ButtonDownInfo buttondown
ViewportWindowviewport
 curwindow dynamically cast to ViewportWindow. Thus, it will be NULL if it is not a ViewportWindow.
Laxkit::Displayerdp
 The Displayer used by the controlling window.

Detailed Description

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.

Todo:

********* 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.


Member Function Documentation

int LaxInterfaces::RectInterface::AlternateScan ( flatpoint  sp,
flatpoint  p,
double  xmag,
double  ymag,
double  onepix 
)
virtual

This is called from the ordinary scan(), but with some things computed already. Use this when adding extra doodads for object control. Custom controls must return values greater than RP_MAX.

Default is return RP_None.

Referenced by scan().

void LaxInterfaces::RectInterface::deletedata ( )
virtual

Dec count data, setting data and somedata to NULL.

References Laxkit::anObject::dec_count().

Referenced by LBDown(), and UseThis().

int LaxInterfaces::RectInterface::FakeLBDown ( int  x,
int  y,
unsigned int  state,
int  count,
const Laxkit::LaxMouse d 
)
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.

int LaxInterfaces::RectInterface::GetMode ( )
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.

void LaxInterfaces::RectInterface::GetOuterRect ( Laxkit::DoubleBBox box,
double *  mm 
)
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().

flatpoint LaxInterfaces::RectInterface::getpoint ( int  c,
int  trans 
)
virtual

If (trans) then transform the data space point by somedata->m().

  x+—- >
  y 1    8    7

  • 2 9 6 | 3 4 5 v

References Laxkit::transform_point().

Referenced by LaxInterfaces::EllipseInterface::getpoint(), MouseMove(), and Refresh().

int LaxInterfaces::RectInterface::KeyUp ( unsigned int  ch,
unsigned int  state,
const Laxkit::LaxKeyboard d 
)
virtual

Shift/noshift toggles end/start point

Reimplemented from LaxInterfaces::anInterface.

References Laxkit::ButtonDownInfo::any(), and LaxInterfaces::anInterface::needtodraw.

int LaxInterfaces::RectInterface::LBDown ( int  x,
int  y,
unsigned int  state,
int  count,
const Laxkit::LaxMouse d 
)
virtual
int LaxInterfaces::RectInterface::MouseMove ( int  x,
int  y,
unsigned int  state,
const Laxkit::LaxMouse mouse 
)
virtual
int LaxInterfaces::RectInterface::Refresh ( )
virtual
int LaxInterfaces::RectInterface::scan ( int  x,
int  y 
)
virtual

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().

void LaxInterfaces::RectInterface::syncFromData ( int  first)
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().

int LaxInterfaces::RectInterface::UseThis ( Laxkit::anObject newdata,
unsigned int   
)
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.

Todo:
*** figure out how this jives with viewport window, especially when this is working on the same data that another interface is working on.. often this will be a child of another interface...

Reimplemented from LaxInterfaces::anInterface.

References deletedata(), Laxkit::anObject::inc_count(), LaxInterfaces::anInterface::needtodraw, and syncFromData().

Referenced by LaxInterfaces::EllipseInterface::EllipseInterface().


Member Data Documentation

char LaxInterfaces::RectInterface::dragmode
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.


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

Mon Feb 17 2014 11:52:58, Laxkit