Laxkit
0.0.7.1
|
Basic data type for interfaces. More...
Public Member Functions | |
virtual void | touchContents () |
virtual Laxkit::LaxImage * | GetPreview () |
If usepreview==1 and preview, then return preview. | |
virtual void | GeneratePreview (int w, int h) |
Create a preview image with transparency for a cached screen preview. | |
virtual int | renderToBuffer (unsigned char *buffer, int bufw, int bufh, int bufstride, int bufdepth, int bufchannels) |
Render the object to a buffer. | |
virtual const char * | Id () |
virtual const char * | Id (const char *newid) |
SomeData () | |
SomeData (double nminx, double nmaxx, double nminy, double nmaxy) | |
Constructor, setting the bounds. | |
virtual const char * | whattype () |
virtual void | FindBBox () |
Theoretically, find and set the bounds of the data. | |
virtual flatpoint | BBoxPoint (double x, double y, bool transform_to_parent) |
virtual flatpoint | ReferencePoint (int which, bool transform_to_parent) |
virtual SomeData * | duplicate (SomeData *dup) |
Duplicate *this. | |
virtual int | pointin (flatpoint pp, int pin=1) |
Return if pp transformed to data coords is within the bounds. | |
virtual int | fitto (double *boxm, DoubleBBox *box, double alignx, double aligny, int whentoscale=2) |
Fit this data to box. | |
virtual SomeData * | GetParent () |
virtual void | dump_out (FILE *f, int indent, int what, Laxkit::anObject *context) |
virtual void | dump_in (FILE *f, int indent, Laxkit::anObject *context, LaxFiles::Attribute **Att=NULL) |
Dump in an attribute, then call dump_in_atts(thatatt,0). | |
virtual void | dump_in_atts (LaxFiles::Attribute *att, int flag, Laxkit::anObject *context) |
Reverse of dump_out(). | |
virtual LaxFiles::Attribute * | dump_out_atts (LaxFiles::Attribute *att, int what, Laxkit::anObject *savecontext) |
Public Member Functions inherited from Laxkit::anObject | |
anObject () | |
Set object_id=getUniqueNumber(). | |
virtual | ~anObject () |
Empty virtual destructor. | |
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 Member Functions inherited from Laxkit::Affine | |
Affine (const double *m) | |
If mm==NULL, set identity. | |
Affine (const Affine &m) | |
Affine (double xx, double xy, double yx, double yy, double tx, double ty) | |
Affine & | operator= (Affine const &m) |
Affine & | operator*= (Affine const &m) |
Affine | operator* (Affine const m) |
virtual void | set (Affine a) |
virtual void | setIdentity () |
virtual bool | isIdentity () |
virtual void | setRotation (double angle) |
virtual void | setScale (double sx, double sy) |
virtual void | setBasis (flatpoint o, flatpoint x, flatpoint y) |
virtual void | setBasics (double x, double y, double sx, double sy, double angle, double shear) |
virtual void | getBasics (double *x, double *y, double *sx, double *sy, double *angle, double *shear) |
virtual void | Translate (flatvector d) |
virtual void | Rotate (double angle) |
virtual void | Rotate (double angle, flatpoint around_point) |
virtual void | RotatePointed (flatpoint anchor1, flatpoint anchor2, flatpoint newanchor2) |
virtual void | RotateScale (flatpoint anchor1, flatpoint anchor2, flatpoint newanchor2) |
Rotate and scale so that anchor1 stays fixed, but anchor2 is shifted to newanchor2. | |
virtual void | Stretch (flatpoint anchor1, flatpoint anchor2, flatpoint newanchor2) |
virtual void | AnchorShear (flatpoint anchor1, flatpoint anchor2, flatpoint anchor3, flatpoint newanchor3) |
Transform so that anchor1 and 2 stay fixed, but anchor3 is shifted to newanchor3. | |
virtual void | Scale (double s) |
virtual void | Scale (flatpoint o, double s) |
Scale around point o. | |
virtual void | Scale (flatpoint o, double sx, double sy) |
virtual void | Scale (flatpoint anchor1, flatpoint anchor2, flatpoint newanchor2) |
Scale as if you move anchor2 to newanchor2, while anchor1 stays the same. | |
virtual void | FlipH () |
virtual void | FlipV () |
virtual void | Flip (flatpoint f1, flatpoint f2) |
Flip across the axis of f1 to f2. | |
virtual void | Multiply (Affine &m) |
this=this*m | |
virtual void | PreMultiply (Affine &m) |
this=m*this | |
virtual Affine | Inversion () |
Return a new matrix that is the inverse of this, if possible. | |
virtual void | Invert () |
Make this the inverse of whatever it is. | |
virtual flatpoint | transformPoint (flatpoint p) |
virtual flatpoint | transformPointInverse (flatpoint p) |
virtual flatpoint | transformVector (flatpoint p) |
Apply the transfrom, but ignore this's translation component. | |
virtual const double * | m () const |
virtual void | m (const double *mm) |
virtual void | m (double xx, double xy, double yx, double yy, double tx, double ty) |
virtual double | m (int c) |
virtual void | m (int c, double v) |
virtual void | Unshear (int preserve_x, int normalize) |
Clear shearing and unequal scaling. Null vectors stay null vectors. | |
virtual void | Normalize () |
Make x and y both be unit vectors, but point in the same direction as before. | |
virtual flatpoint | origin () |
virtual void | origin (flatpoint o) |
virtual flatpoint | xaxis () |
virtual void | xaxis (flatpoint x) |
virtual flatpoint | yaxis () |
virtual void | yaxis (flatpoint y) |
Public Member Functions inherited from Laxkit::DoubleBBox | |
DoubleBBox () | |
Create empty invalid bbox (maxx<minx and maxy<miny). | |
DoubleBBox (flatpoint p) | |
Create box whose bounds are p. | |
DoubleBBox (double mix, double max, double miy, double may) | |
Create box whose bounds are as given. | |
virtual void | clear () |
Make box invalid: set minx=miny=0 and maxx=maxy=-1. | |
virtual void | addtobounds (double x, double y) |
virtual void | addtobounds (flatpoint p) |
Expand bounds to contain p. Set the bounds to p if current bounds are invalid. | |
virtual void | addtobounds (DoubleBBox *bbox) |
Add the bbox to the bounds. Set the bounds if current bounds are invalid. | |
virtual void | addtobounds (const double *m, DoubleBBox *bbox) |
Add bbox to bounds, first transforming it by 6 element transform matrix m. | |
virtual void | setbounds (DoubleBBox *bbox) |
Just copy over the bounds. | |
virtual void | setbounds (flatpoint *pts, int n) |
Make this bbox be the bounds for the given n points. (does not add to previous bounds) | |
virtual void | setbounds (double mix, double max, double miy, double may) |
Set the bounds to the specified values. | |
virtual int | validbounds () |
Returns maxx>=minx && maxy>=miny. | |
virtual int | intersect (double mix, double max, double miy, double may, int settointersection=0) |
Intersect the given bounds with this's bounds. Return 1 for non-empty intersection. | |
virtual int | intersect (DoubleBBox *bbox, int settointersection=0) |
Just return intersect(bbox.minx,...,settointersection). | |
virtual int | intersect (double *m, DoubleBBox *bbox, int touching, int settointersection) |
Does the transformed box touch. **** incomplete implementation. | |
virtual int | boxcontains (double x, double y) |
Return whether the given point is contained within or on the bounds. | |
virtual flatpoint | BBoxPoint (double x, double y) |
Public Attributes | |
Laxkit::LaxImage * | preview |
A preview image potentially to be used to not have to rerender on each refresh. | |
int | usepreview |
Flag for whether to use SomeData::preview rather than rendering. | |
std::time_t | previewtime |
The time the preview was generated, if at all, as returned by time(). | |
std::time_t | modtime |
The time of last modification through a SomeData function. | |
int | bboxstyle |
flatpoint | centerpoint |
unsigned int | flags |
int | iid |
Id of the interface that should handle this data. | |
char * | nameid |
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 |
Public Attributes inherited from Laxkit::DoubleBBox | |
double | minx |
double | maxx |
double | miny |
double | maxy |
Additional Inherited Members | |
Protected Attributes inherited from Laxkit::anObject | |
int | _count |
The reference count of the object. | |
Protected Attributes inherited from Laxkit::Affine | |
double | _m [6] |
Basic data type for interfaces.
Defines a 2 dimensional basis, plus min and max bounds. These bounds are in the object's own space, not transformed by matrix. For instance, (actual x,y)=(object x,y)*transform, where:
transform = [ m[0] m[2] 0 ], and points are [ x ] [ m[1] m[3] 0 ] [ y ] [ m[4] m[5] 1 ] [ 1 ]
LaxInterfaces::SomeData::SomeData | ( | ) |
Object is created with a count of 1.
LaxInterfaces::SomeData::SomeData | ( | double | nminx, |
double | nmaxx, | ||
double | nminy, | ||
double | nmaxy | ||
) |
Constructor, setting the bounds.
Object is created with a count of 1.
|
virtual |
Like Laxkit::DoubleBBox::BBoxPoint(x,y), but if transform_to_parent==true, then transform the point by m().
|
virtual |
Dump in an attribute, then call dump_in_atts(thatatt,0).
If Att!=NULL, then return the attribute used to read in the stuff. This allows holding classes to have extra attributes within the spot field to exist and not be discarded.
***perhaps?: The fields actually used are removed from the attribute?
References LaxFiles::Attribute::dump_in().
Duplicate *this.
If dup!=NULL, then copy all relevant portions of this to dup. This might occur when taking a shortcut to duplicate components of super classes.
If dup==NULL, then return a brand new copy of this object. In this case, subclasses should first call somedatafactory->newObject(object_type, reference) and return that if any, before creating one of itself.
bboxstyle and the matrix are copied over here.
Reimplemented in LaxInterfaces::ImageData.
References LaxInterfaces::SomeDataFactory::newObject(), Laxkit::DoubleBBox::setbounds(), and LaxInterfaces::somedatafactory.
|
inlinevirtual |
Theoretically, find and set the bounds of the data.
As this usually requires further knowledge of the particular interface used, this function is perhaps not very useful...
Reimplemented in LaxInterfaces::PathsData, LaxInterfaces::PatchData, LaxInterfaces::PointWarpData, LaxInterfaces::GradientData, and LaxInterfaces::CaptionData.
|
virtual |
Fit this data to box.
This adjusts this->matrix so that this's bounds lie within the box transformed by boxm. To put it differently, make this fit in another SomeData's bounding box. This will take on the box's matrix, and then the scaling and origin are adjusted so this's bounding box fits inside box. Note that this is very different than merely visually translating and scaling this so that it fits in the transformed box, because this is rotated to have axes parallel to box.
this->m() transforms this to its parent space, and it is assumed that boxm transforms the box also to this's parent space.
If boxm==NULL, then assume the axes are aligned properly already, and we only need to adjust the origin and scaling. It has the same effect as when boxm==this->m().
If this does not fit exactly, then the alignx and aligny specify how to fit in the leftover space. 0 means at bottom or left, 100 means at top or right, 50 means center, and other values are everything else in between.
If whentoscale==0, then never scale, just align. If ==1, then scale down if necessary, but not up if smaller than box. Else scale up and down to fit to bounds
Return 0 for success, or 1 for error, for instance if box or this had invalid bounds.
References Laxkit::transform_point().
Referenced by LaxInterfaces::ImageData::LoadImage().
Create a preview image with transparency for a cached screen preview.
This will return immediately if usepreview!=1 or the bounds are not valid. If w or h are less than or equal to 0, then use default or previous values for them. The default is to fit within a box 200x200, with aspect approximately the same as the object's bounding box.
Subclasses need not redefine this function. They need only redefine renderToBuffer().
|
virtual |
If usepreview==1 and preview, then return preview.
If previewtime>modtime, then call GeneratePreview(-1,-1) before returning preview.
Referenced by LaxInterfaces::GradientInterface::Refresh(), LaxInterfaces::PointWarpInterface::Refresh(), and LaxInterfaces::PatchInterface::Refresh().
|
virtual |
If id is blank, then try to create a unique one.
References Laxkit::make_id(), and makestr().
Referenced by LaxInterfaces::SomeDataRef::Set(), and LaxInterfaces::SomeDataRef::SomeDataRef().
Return if pp transformed to data coords is within the bounds.
unimplemented: in=1 | on=2 | out=0
Reimplemented in LaxInterfaces::PatchData, and LaxInterfaces::GradientData.
References Laxkit::transform_invert(), and Laxkit::transform_point().
Referenced by LaxInterfaces::ViewportWithStack::FindObject(), LaxInterfaces::ImageInterface::LBDown(), and LaxInterfaces::RectInterface::LBDown().
which is one of Laxkit::BBoxReferencePoint. If transform_to_parent, return the point transformed by m().
|
virtual |
Render the object to a buffer.
This draws onto buffer such that the object's whole bounding box maps to the whole buffer.
This is mainly used to create screen previews in ARGB 8 bit format. Maybe someday it will be more powerful!!
Default here is just a do nothing placeholder, and only returns 1. On success, it should return 0.
Reimplemented in LaxInterfaces::PatchData, and LaxInterfaces::GradientData.
int LaxInterfaces::SomeData::iid |
Id of the interface that should handle this data.
This is only a hint. Nothing in Laxkit depends on it.
time_t LaxInterfaces::SomeData::modtime |
Laxkit::LaxImage * LaxInterfaces::SomeData::preview |
A preview image potentially to be used to not have to rerender on each refresh.
This is an image that scales to the bounds of the data without skewing. Thus, matrix is not applied before rendered. Usually the Displayer will apply any additional transform before compositing to its surface.
time_t LaxInterfaces::SomeData::previewtime |
The time the preview was generated, if at all, as returned by time().
Beware that this is a time in seconds.