2#ifndef _2GEOM_TOY_FRAMEWORK2_H_
3#define _2GEOM_TOY_FRAMEWORK2_H_
62 virtual void load(FILE* f)=0;
63 virtual void save(FILE* f)=0;
74 void draw(
cairo_t *cr,
bool annotes =
false)
override;
80 void load(FILE* )
override { }
81 void save(FILE* )
override { }
96 it->draw(cr, annotes);
105 if (
result != NULL)
break;
161 typedef typename std::vector<T>::iterator
iterator;
172 void draw(
cairo_t *cr,
bool annotes =
false)
override;
176 void load(FILE* f)
override;
177 void save(FILE* f)
override;
183 std::vector<Geom::Point>
pts;
184 void draw(
cairo_t *cr,
bool annotes =
false)
override;
192 void load(FILE* f)
override;
193 void save(FILE* f)
override;
202 void draw(
cairo_t *cr,
bool annotes =
false)
override;
206 void load(FILE* f)
override;
207 void save(FILE* f)
override;
214 std::ostringstream os;
245 value_type _value,
const std::string& _label =
"" )
275 void draw(
cairo_t* cr,
bool annotate =
false)
override;
332 virtual void draw(
cairo_t *cr, std::ostringstream *notify,
int w,
int h,
bool save, std::ostringstream *timing_stream);
340 virtual void key_hit(
unsigned keyval,
unsigned modifiers) {}
349 virtual void load(FILE* f);
350 virtual void save(FILE* f);
399#if ! (defined(_WIN32) || defined(__APPLE__))
414#if ! (defined(_WIN32) || defined(__APPLE__))
416# ifdef _POSIX_THREAD_CPUTIME
417 static const clockid_t
clock = CLOCK_THREAD_CPUTIME_ID;
419# ifdef CLOCK_MONOTONIC
420 static const clockid_t
clock = CLOCK_MONOTONIC;
422 static const clockid_t
clock = CLOCK_REALTIME;
428inline std::ostream& operator<<(std::ostream& o,
Timer::Time const &t) {
431 char prefixes[] =
"num kMGT";
432 while(prefix <
sizeof(prefixes) and tm > 1000) {
436 o << tm << prefixes[prefix] <<
"s";
Defines the different types of exceptions that 2geom can throw.
Various geometrical calculations.
Cartesian point / 2D vector and related operations.
pair< double, double > Point
Adaptor that creates 2D functions from 1D ones.
Two-dimensional point that doubles as a vector.
Axis aligned, non-empty rectangle.
virtual void save(FILE *f)=0
virtual void move_to(void *hit, Geom::Point om, Geom::Point m)=0
virtual void load(FILE *f)=0
virtual void * hit(Geom::Point pos)=0
virtual void draw(cairo_t *cr, bool annotes=false)=0
PointHandle(double x, double y)
void draw(cairo_t *cr, bool annotes=false) override
void load(FILE *f) override
void move_to(void *hit, Geom::Point om, Geom::Point m) override
void save(FILE *f) override
void * hit(Geom::Point mouse) override
PointHandle(Geom::Point pt)
void load(FILE *f) override
void move_to(void *hit, Geom::Point om, Geom::Point m) override
void push_back(double x, double y)
void save(FILE *f) override
void push_back(Geom::Point pt)
void draw(cairo_t *cr, bool annotes=false) override
void * hit(Geom::Point mouse) override
Geom::D2< Geom::SBasis > asBezier()
std::vector< Geom::Point > pts
void move_to(void *hit, Geom::Point om, Geom::Point m) override
void draw(cairo_t *cr, bool annotes=false) override
RectHandle(Geom::Rect pos, bool show_center_handle)
void load(FILE *f) override
void * hit(Geom::Point mouse) override
void save(FILE *f) override
value_type max_value() const
void draw(cairo_t *cr, bool annotate=false) override
void load(FILE *f) override
value_type min_value() const
void * hit(Geom::Point pos) override
void geometry(Geom::Point _pos, value_type _length, Geom::Dim2 _dir=Geom::X)
void save(FILE *f) override
void set(value_type _min, value_type _max, value_type _step, value_type _value, const std::string &_label="")
Slider(value_type _min, value_type _max, value_type _step, value_type _value, std::string _label="")
void formatter(formatter_t _formatter)
std::string(* formatter_t)(double)
void move_to(void *hit, Geom::Point om, Geom::Point m) override
Time(long long, long long l)
Time operator/(double iters) const
void ask_for_timeslice()
Ask the OS nicely for a big time slice.
static const clockid_t clock
void save(FILE *) override
void load(FILE *) override
void move_to(void *, Geom::Point, Geom::Point) override
Toggle(Geom::Rect bnds, const char *txt, bool v)
Toggle(const char *txt, bool v)
void handle_click(Geom::Point const &pos, unsigned button)
void draw(cairo_t *cr, bool annotes=false) override
void * hit(Geom::Point pos) override
virtual void first_time(int, char **)
virtual void canvas_click(Geom::Point at, int button)
virtual void load(FILE *f)
virtual void mouse_pressed(Geom::Point const &pos, unsigned button, unsigned modifiers)
Geom::Point old_mouse_point
virtual int should_draw_bounds()
virtual void mouse_moved(Geom::Point const &pos, unsigned modifiers)
virtual bool should_draw_numbers()
vector< Handle * > handles
virtual void mouse_released(Geom::Point const &pos, unsigned button, unsigned modifiers)
virtual void save(FILE *f)
virtual void resize_canvas(Geom::Rect const &)
virtual void key_hit(unsigned keyval, unsigned modifiers)
virtual void draw(cairo_t *cr, std::ostringstream *notify, int w, int h, bool save, std::ostringstream *timing_stream)
virtual void scroll(GdkScrollDirection dir, Geom::Point const &delta)
void * hit(Geom::Point pos) override
void save(FILE *f) override
void push_back(const T &_handle)
const T & operator[](size_t i) const
void load(FILE *f) override
std::vector< T >::iterator iterator
std::vector< T > m_handles
void move_to(void *hit, Geom::Point om, Geom::Point m) override
void draw(cairo_t *cr, bool annotes=false) override
Lifts one dimensional objects into 2D.
Dim2
2D axis enumeration (X or Y).
Various utility functions.
Polynomial in symmetric power basis (S-basis)
static colour from_hsl(float H, float S, float L, float A)
colour(double r, double g, double b, double a)
static colour from_hsv(float H, float S, float V, float A)
void draw_text(cairo_t *cr, Geom::Point pos, const char *txt, bool bottom=false, const char *fontdesc="Sans")
void toggle_events(std::vector< Toggle > &ts, Geom::Point const &pos, unsigned button)
const long long NS_PER_SECOND
Geom::Point read_point(FILE *f)
void cairo_set_source_rgba(cairo_t *cr, colour c)
void get_clipboard_text(std::function< void(char const *)> &&on_completion)
void draw_number(cairo_t *cr, Geom::Point pos, int num, std::string name=std::string(), bool bottom=true)
std::string default_formatter(double x)
const long long NS_PER_NS
void draw_toggles(cairo_t *cr, std::vector< Toggle > &ts)
void init(int argc, char **argv, Toy *t, int width=600, int height=600)
void take_screenshot(const char *file)