include/liqsketch.h

00001 /* liqbase
00002  * Copyright (C) 2008 Gary Birkett
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License version 2
00006  * as published by the Free Software Foundation.
00007  *
00008  * This program is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  * GNU General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License
00014  * along with this program; if not, write to the Free Software
00015  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00016  */
00017 
00018 /*
00019  *
00020  * Header for basic sketch
00021  *
00022  */
00023 
00024 
00025 
00026 
00027 #ifndef LIQSKETCH_H
00028 #define LIQSKETCH_H
00029 
00030 
00031 #include "liqimage.h"
00032 
00033 //struct liqtile;
00034 
00035 
00036 struct liqcell; // 20090422_194042 lcuk : todo - sort out this cycling dependency
00037 
00038 
00039 //##################################################################
00040 
00041 typedef struct liqpoint
00042 {
00043         unsigned int usagecount;
00044         struct liqpoint *linkprev;
00045         struct liqpoint *linknext;
00046         int           x;
00047         int           y;
00048         int           z;        
00049         unsigned long t;
00050 } liqpoint;
00051 
00052 //liqpoint         *liqpoint_alloc();
00053 //void          liqpoint_new(liqpoint *self);
00054 //void          liqpoint_free(liqpoint *self);
00055 
00056 liqpoint *      liqpoint_new();
00057 liqpoint *      liqpoint_hold(liqpoint *self);
00058 void                    liqpoint_release(liqpoint *self);
00059 void                    liqpoint_free(liqpoint *self);
00060 
00061 
00062 
00063 
00064 liqpoint         *liqpoint_clone(liqpoint *s);
00065 inline void   liqpoint_copy(liqpoint *self,liqpoint *s) ;
00066 inline void   liqpoint_getdiff(liqpoint *self,liqpoint *s,liqpoint *e) ;
00067 inline int    liqpoint_issame(liqpoint *self,liqpoint *s);
00068 
00069 //##################################################################
00070 
00071 typedef struct liqpointrange
00072 {
00073         int xl;
00074         int yt;
00075         int xr;
00076         int yb;
00077         int zf;
00078         int zb;
00079 } liqpointrange;
00080 void          liqpointrange_start(liqpointrange *self,liqpoint *p);
00081 void          liqpointrange_extendrubberband(liqpointrange *self,liqpoint *p);
00082 
00083 //##################################################################
00084 typedef struct liqstroke 
00085 {
00086         unsigned int usagecount;
00087         struct liqstroke *linkprev;
00088         struct liqstroke *linknext;
00089         
00090         struct liqsketch   *linkpage;
00091         
00092         unsigned char pen_y;            // todo we can pack these nowadays ;)
00093         unsigned char pen_u;            // infact, we can style them :)
00094         unsigned char pen_v;            // hmmm..
00095         unsigned char pen_thick;
00096         
00097         int           strokekind;       // 0=normal stroke, 1=p2p line, 2=box, 3=areafill
00098         
00099         short             selected;
00100         short         islandnumber;
00101         
00102         char *            mediakey;             // filename used as xref for image or subtile.  when selected the file should be moved into the project folder
00103         // media is the key into another page
00104         
00105         struct liqsketch   *mediapage;  // this is NOT freed here, it is YOUR job to handle it
00106         
00107         // normalization involves scaling to unit
00108         char              *quadchain;   // the results of normalizing the stroke and building a quadchain list
00109         
00110         int           pointcount;
00111         liqpoint         *pointfirst;
00112         liqpoint         *pointlast;
00113         liqpointrange    boundingbox;
00114         
00115 
00116 } liqstroke;
00117 
00118 
00119 liqstroke *     liqstroke_new();
00120 liqstroke *     liqstroke_hold(liqstroke *self);
00121 void                    liqstroke_release(liqstroke *self);
00122 void                    liqstroke_free(liqstroke *self);
00123 
00124 
00125 //liqstroke        *liqstroke_alloc();
00126 //void          liqstroke_new(liqstroke *self);
00127 //void          liqstroke_free(liqstroke *self);
00128 
00129 
00130 void          liqstroke_clear(liqstroke *self);
00131 
00132 liqstroke        *liqstroke_clone(liqstroke *s);
00133 void              liqstroke_appendpoint(liqstroke *self,liqpoint *p);
00134 
00135 void          liqstroke_start(liqstroke *self,int px,int py, int pz,unsigned long pt);
00136 void          liqstroke_extend(liqstroke *self,int px,int py, int pz,unsigned long pt);
00137 int           liqstroke_totallength(liqstroke *self);
00138 void          liqstroke_ensurepositive(liqstroke *self);
00139 int           liqstroke_hittest(liqstroke *self,int px,int py);
00140 char *        liqstroke_quadchainbuild(liqstroke *self);
00141 
00142 
00143 //##################################################################
00144 typedef struct liqsketch 
00145 {
00146         unsigned int            usagecount;
00147         //void *                        owner;
00148         
00149         int                     pixelwidth;
00150         int                     pixelheight;
00151 
00152         int                     dpix;
00153         int                     dpiy;
00154         
00155         char          *         title;
00156         char          *         filename;
00157         int                             islandcount;
00158         
00159         int                     strokecount;
00160         liqstroke        *      strokefirst;
00161         liqstroke        *      strokelast;
00162         //liqstroke        *strokecurrent;
00163         liqpointrange           boundingbox;
00164         
00165         
00166         int                     backgroundstyle;                // 0 none, 1=solid,2=image,3=subsketch..
00167         unsigned int            backgroundcoloryuv;
00168         char *                          backgroundfilename;
00169         liqimage *                      backgroundimage;
00170         struct liqsketch *      backgroundsketch;
00171 
00172         
00173         //struct liqcell *              extratokens;                    // a set of tokens which did not match the normal defs, loaded and saved with the file                  
00174         
00175 
00176 } liqsketch;
00177 
00178 
00179 
00180 
00181 liqsketch       *       liqsketch_newfromfile(char *filename);
00182 
00183 liqsketch *     liqsketch_new();
00184 liqsketch *     liqsketch_hold(liqsketch *self);
00185 void                    liqsketch_release(liqsketch *self);
00186 void                    liqsketch_free(liqsketch *self);
00187 
00188 
00189 
00190 void          liqsketch_titlechange(liqsketch *self,char *title);
00191 
00192 void          liqsketch_strokeinsert(liqsketch *self,liqstroke *s);
00193 void          liqsketch_strokeupdate(liqsketch *self,liqstroke *s);
00194 void          liqsketch_strokeremove(liqsketch *self,liqstroke *s);
00195 void          liqsketch_clear(liqsketch *self);
00196 
00197 int               liqsketch_filesave(liqsketch *self,char *filename);
00198 int               liqsketch_fileload(liqsketch *self,char *filename);
00199 
00200 void          liqsketch_boundwholearea();
00201 
00202 void              liqsketch_coordchange_scr_to_page(liqsketch *self,int scrx,int scry,int scrw,int scrh, int scrdpix,int scrdpiy,int *rx,int *ry);
00203 void              liqsketch_islandcalcall(liqsketch *self);             // identify the islands within this page :)
00204 
00205 
00206 #endif

Generated on Sat May 23 23:03:14 2009 for libliqbase by  doxygen 1.5.1