Laxkit  0.0.7.1
engraverfillinterface.h
1 //
2 //
3 // The Laxkit, a windowing toolkit
4 // Please consult http://laxkit.sourceforge.net about where to send any
5 // correspondence about this software.
6 //
7 // This library is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU Library General Public
9 // License as published by the Free Software Foundation; either
10 // version 2 of the License, or (at your option) any later version.
11 //
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // Library General Public License for more details.
16 //
17 // You should have received a copy of the GNU Library General Public
18 // License along with this library; if not, write to the Free Software
19 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 //
21 // Copyright (C) 2014 by Tom Lechner
22 //
23 #ifndef _LAX_ENGRAVERFILLINTERFACE_H
24 #define _LAX_ENGRAVERFILLINTERFACE_H
25 
26 #include <lax/interfaces/patchinterface.h>
27 #include <lax/interfaces/pathinterface.h>
28 #include <lax/screencolor.h>
29 #include <lax/curvewindow.h>
30 
31 
32 namespace LaxInterfaces {
33 
34 
35 //------------------------------------- EngraverFillData ------------------------
36 class LinePoint
37 {
38  public:
39  double s,t;
40  int row,col;
41  double weight;
42 
43  bool needtosync;
44  flatpoint p; //(s,t) transformed by the mesh
45 
46  LinePoint *next, *prev;
47 
48  LinePoint() { row=col=0; s=t=0; weight=1; next=NULL; needtosync=true; }
49  LinePoint(double ss, double tt, double ww) { next=NULL; s=ss; t=tt; weight=ww; }
50 
51  void Set(double ss,double tt, double nweight) { s=ss; t=tt; if (nweight>=0) weight=nweight; needtosync=true; }
52  void Clear();
53  void Add(LinePoint *np);
54 };
55 
57 {
58  protected:
59 
60  public:
62  flatvector direction;
63  int nlines;
64  FillStyle fillstyle;
65 
67  //EngraverFillData(double xx,double yy,double ww,double hh,int nr,int nc,unsigned int stle);
68  virtual ~EngraverFillData();
69  virtual const char *whattype() { return "EngraverFillData"; }
70  virtual SomeData *duplicate(SomeData *dup);
71 
72  virtual void dump_out(FILE *f,int indent,int what,Laxkit::anObject *context);
73  virtual void dump_in_atts(LaxFiles::Attribute *att,int flag,Laxkit::anObject *context);
74  virtual void dump_out_svg(const char *file);
75  virtual PathsData *MakePathsData();
76 
77  virtual void Set(double xx,double yy,double ww,double hh,int nr,int nc,unsigned int stle);
78  //virtual unsigned long WhatColorLong(double s,double t);
79  //virtual int WhatColor(double s,double t,Laxkit::ScreenColor *color_ret);
80  //virtual int hasColorData();
81 
82  //virtual void zap();
83 
84  virtual void FillRegularLines(double weight, double spacing);
85  virtual void FillRegularLinesHorizontal(double weight);
86  virtual void Sync();
88 };
89 
90 
91 //------------------------------ EngraverFillInterface -------------------------------
92 
93 
95 {
96  protected:
97  EngraverFillData *edata;
98  int mode;
99  double brush_radius; //screen pixels
100  Laxkit::CurveInfo thickness; //ramp of thickness brush
101  double default_spacing;
102  flatpoint hover;
103 
104  //virtual void runImageDialog();
105  virtual int PerformAction(int action);
106  public:
108  virtual ~EngraverFillInterface();
109  virtual Laxkit::ShortcutHandler *GetShortcuts();
110  virtual const char *IconId() { return "Engraver"; }
111  virtual const char *Name();
112  virtual const char *whattype() { return "EngraverFillInterface"; }
113  virtual const char *whatdatatype() { return "EngraverFillData"; }
114  virtual anInterface *duplicate(anInterface *dup);
115  virtual int UseThisObject(ObjectContext *oc);
116  virtual int UseThis(anObject *newdata,unsigned int mask=0);
117  virtual int UseThis(int id,int ndata);
118  virtual int DrawData(anObject *ndata,anObject *a1=NULL,anObject *a2=NULL,int info=0);
119  virtual int LBDown(int x,int y,unsigned int state,int count,const Laxkit::LaxMouse *d);
120  virtual int LBUp(int x,int y,unsigned int state,const Laxkit::LaxMouse *d);
121  virtual int MouseMove(int x,int y,unsigned int state,const Laxkit::LaxMouse *d);
122  virtual int CharInput(unsigned int ch,const char *buffer,int len,unsigned int state,const Laxkit::LaxKeyboard *d);
123  virtual int KeyUp(unsigned int ch,unsigned int state,const Laxkit::LaxKeyboard *d);
124  virtual int Refresh();
125  virtual int Event(const Laxkit::EventData *data, const char *mes);
126 
127  virtual void deletedata();
128  virtual PatchData *newPatchData(double xx,double yy,double ww,double hh,int nr,int nc,unsigned int stle);
129  //virtual void drawpatch(int roff,int coff);
130  //virtual void patchpoint(PatchRenderContext *context, double s0,double ds,double t0,double dt,int n);
131 };
132 
133 } //namespace LaxInterfaces
134 
135 #endif
136 
137 

Mon Feb 17 2014 11:52:56, Laxkit