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

Interface for dealing with ImagePatchData objects. More...

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

List of all members.

Public Member Functions

 ImagePatchInterface (int nid, Laxkit::Displayer *ndp)
virtual ~ImagePatchInterface ()
 Empty destructor.
virtual Laxkit::ShortcutHandlerGetShortcuts ()
virtual const charIconId ()
virtual const charName ()
virtual const charwhattype ()
virtual const charwhatdatatype ()
virtual anInterfaceduplicate (anInterface *dup)
virtual int UseThisObject (ObjectContext *oc)
virtual int UseThis (anObject *newdata, unsigned int mask=0)
virtual int UseThis (int id, int ndata)
 id==4 means make recurse=ndata.
virtual int DrawData (anObject *ndata, anObject *a1=NULL, anObject *a2=NULL, int info=0)
 Checks for ImagePatchData, then calls PatchInterface::DrawData(ndata,a1,a2,info).
virtual int LBDown (int x, int y, unsigned int state, int count, const Laxkit::LaxMouse *d)
 Catch a double click to pop up an ImageDialog.
virtual int CharInput (unsigned int ch, const char *buffer, int len, unsigned int state, const Laxkit::LaxKeyboard *d)
virtual PatchDatanewPatchData (double xx, double yy, double ww, double hh, int nr, int nc, unsigned int stle)
 Return new local ImagePatchData.
virtual void drawpatch (int roff, int coff)
 Draws one patch to the screen. Called from PatchInterface::Refresh().
virtual void patchpoint (PatchRenderContext *context, double s0, double ds, double t0, double dt, int n)
 Called from drawpatch(). No recursion, just draw a bunch of rects for patch.
- Public Member Functions inherited from LaxInterfaces::PatchInterface
 PatchInterface (int nid, Laxkit::Displayer *ndp)
virtual int UseThis (Laxkit::anObject *newdata, unsigned int mask=0)
virtual void Clear (SomeData *d=NULL)
 Delete data, and flush curpoints. Make needtodraw=1.
virtual int InterfaceOn ()
virtual int InterfaceOff ()
 Flush curpoints.
virtual ObjectContextContext ()
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 KeyUp (unsigned int ch, unsigned int state, const Laxkit::LaxKeyboard *d)
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 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::MenuInfoContextMenu (int x, int y, int deviceid)
 Return a context sensitive menu for screen position (x,y).
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 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.

Protected Member Functions

virtual void runImageDialog ()
virtual int PerformAction (int action)
- Protected Member Functions inherited from LaxInterfaces::PatchInterface
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().

Protected Attributes

ImagePatchDataipdata
- Protected Attributes inherited from LaxInterfaces::PatchInterface
double movetransform [6]
flatpointmovepts
flatpoint lbdown
flatpointcuth
flatpointcutv
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< intcurpoints
int mousedragged
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.

Additional Inherited Members

- Public Types inherited from LaxInterfaces::PatchInterface
enum  PatchDecorations { SHOW_Grid = (1<<0), SHOW_Points = (1<<1), SHOW_Edges = (1<<2), SHOW_Max = (1<<3) }
- Public Attributes inherited from LaxInterfaces::PatchInterface
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.
PatchDatadata
ObjectContextpoc
- 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.
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::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.

Detailed Description

Interface for dealing with ImagePatchData objects.

Todo:
***when inserting new image, should have option to preserve the scale, so if aspect of old image was 2, and new image is 1, then do the same for the aspect of the patch as a whole, or have the image space map to a subset of the patch space, rather than always [0..1]

Member Function Documentation

void LaxInterfaces::ImagePatchInterface::drawpatch ( int  roff,
int  coff 
)
virtual

Draws one patch to the screen. Called from PatchInterface::Refresh().

The whole patch is made of potentially a whole lot of adjacent patches. If rendermode==0, then just draw the wire outline. Otherwise do the whole color thing.

This function prepares Cx and Cy matrices for patchpoint(). A point in the patch is px=St*Cx*T, py=St*Cy*T.

roff,coff is which patch, point start is == off*3

Todo:
*** when there is no image should do something clever to indicate there is none, like drawing a bezier X across the patch.

Reimplemented from LaxInterfaces::PatchInterface.

References LaxInterfaces::B, Laxkit::bez_bbox(), LaxInterfaces::anInterface::dp, LaxInterfaces::PatchData::getGt(), LaxInterfaces::m_times_m(), Laxkit::Displayer::Maxx, Laxkit::Displayer::Maxy, Laxkit::Displayer::Minx, Laxkit::Displayer::Miny, patchpoint(), Laxkit::Displayer::realtoscreen(), and LaxInterfaces::PatchInterface::rendermode.

void LaxInterfaces::ImagePatchInterface::patchpoint ( PatchRenderContext context,
double  s0,
double  ds,
double  t0,
double  dt,
int  n 
)
virtual

Called from drawpatch(). No recursion, just draw a bunch of rects for patch.

The parameters refer to the color space. They are not coordinates.

n is the number of areas to divide the patch into. s0, t0, ds, dt all refer to the color space.

Finds coords via getSPoint().

Todo:
*** optimize this baby! If going beyond resolution of what is in the color source, should be able back up and draw larger rect...

References LaxInterfaces::anInterface::dp, Laxkit::Displayer::drawlines(), Laxkit::Displayer::DrawReal(), Laxkit::Displayer::DrawScreen(), LaxInterfaces::PatchRenderContext::getPoint(), LaxInterfaces::getT(), LaxInterfaces::ImagePatchData::iheight, LaxInterfaces::ImagePatchData::iwidth, Laxkit::Displayer::NewFG(), and LaxInterfaces::ImagePatchData::WhatColor().

Referenced by drawpatch().

void LaxInterfaces::ImagePatchInterface::runImageDialog ( )
protectedvirtual

This should result in an image properties dialog of some kind being run. This function is called in response to an image patch being double clicked on.

It is assumed that data and curwindow both exist.

Todo:
*** after laxkit event mechanism gets rewritten, the return event would get sent back to this ImageInterface instance, but right now, curwindow has to somehow relay the event to the object in question.

References LaxInterfaces::anInterface::curwindow, Laxkit::anObject::dec_count(), LaxInterfaces::ImagePatchData::filename, and Laxkit::anXApp::rundialog().

Referenced by LBDown().


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

Mon Feb 17 2014 11:52:58, Laxkit