⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 view_base.h

📁 A Library of Efficient Data Types and Algorithms,封装了常用的ADT及其相关算法的软件包
💻 H
字号:
/*******************************************************************************++  LEDA 4.5  +++  view_base.h+++  Copyright (c) 1995-2004+  by Algorithmic Solutions Software GmbH+  All rights reserved.+ *******************************************************************************/// $Revision: 1.3 $  $Date: 2004/02/06 11:18:31 $#ifndef VIEW_BASE_TYPES_H#define VIEW_BASE_TYPES_H#include <LEDA/window.h>#include <LEDA/motion.h>LEDA_BEGIN_NAMESPACEclass view;//---------------------------------------------------------------------------// class base_element// ---------------------------------------------------------------------------class base_element{ protected:  view*     V;      int       rank;  list_item item;    virtual void attach(view& v) { V = &v; };  virtual void detach(view& v) { if (V == &v) V = 0; }    virtual bool is_attached() const { return V != 0; }  virtual bool is_attached(view& v) const { return V == &v; }   virtual void      set_item(list_item it);  virtual list_item get_item() const;   friend class view;    public:   base_element();  base_element(const base_element& x);  base_element& operator=(const base_element& x);      virtual ~base_element() {}  virtual void redraw() = 0;          virtual point     get_position() const = 0;  virtual rectangle get_bounding_box() = 0;    virtual int set_rank(int x);  virtual int get_rank() const;      virtual view& get_view() const { return *V; }  virtual bool intersect(segment,list<point>&) const { return false; }      friend int compare(const base_element* x, const base_element* y)  { if (x->get_rank() == y->get_rank()) return 0;    if (x->get_rank() < y->get_rank()) return 1;    return -1;  }};typedef base_element* elem_item;//---------------------------------------------------------------------------// class relation// ---------------------------------------------------------------------------class base_relation{};//---------------------------------------------------------------------------// class action// --------------------------------------------------------------------------struct base_animation{   virtual void init(int) {}  virtual int  steps() const = 0;    virtual void start() {}  virtual void step() {}  virtual void finish() {}  virtual ~base_animation() {}};typedef base_animation* anim_item;//---------------------------------------------------------------------------// class path// ---------------------------------------------------------------------------class path {  motion_base* P;  bool x;    public:    path();  path(const path& p);  path& operator=(const path& p);   ~path();   template <class motion_t>  path(const motion_t& M)  : P(new motion_t(M)), x(true) {}    path(motion_base*) : P(new linear_motion), x(true) {}    template <class motion_t>  path& operator=(const motion_t& M)  { delete P;     P = new motion_t(M);     return *this;   }    void   get_path(point p0, point p1, int steps, list<point>& L);  double get_path_length(point p0, point p1);  vector get_step(vector v, int steps, int i);};//---------------------------------------------------------------------------// class base_move// --------------------------------------------------------------------------template <class element>class base_move : public base_animation{   protected:    element& S;       // element  view&    V;       // view    point    p1;      // destination    path     Path;    // animation path       list<point> L;    // stores coordinates    int      num;     // max. number of required steps    public:  base_move(element& s, point p) : S(s), V(S.get_view()), p1(p)  { window& W = V.get_window();    num = W.real_to_pix(Path.get_path_length(p1,S.get_position()));   }  base_move(element& s, point p, const path& P) : S(s), V(S.get_view()), p1(p)  { Path = P;      window& W = V.get_window();    num = W.real_to_pix(Path.get_path_length(p1,S.get_position()));   }    void init(int steps)  { Path.get_path(S.get_position(),p1,steps,L); }      int steps() const { return num; }      void step() { S.set_position(L.pop()); }    void finish()  { if (S.get_position() != p1) S.set_position(p1);    delete this;  }};//---------------------------------------------------------------------------// class action// ---------------------------------------------------------------------------struct base_action{   virtual ~base_action() {}           enum   { ACT_LEFT      = (1 << 0),    ACT_MIDDLE    = (1 << 1),    ACT_RIGHT	    = (1 << 2),    ACT_SHIFT	    = (1 << 3),    ACT_CTRL	    = (1 << 4),    ACT_ALT	      = (1 << 5),    ACT_DOUBLE    = (1 << 6),    ACT_DRAG      = (1 << 7),       ACT_RET_TRUE  = (1 << 8),    ACT_RET_FALSE = (1 << 9),    ACT_CONTINUE  = (1 << 10)  };   virtual void    redraw() {}         virtual window* get_window() const = 0;  virtual int     handle_event(int, int, double, double) = 0;};typedef base_action* action_item;LEDA_END_NAMESPACE#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -