File: connection_figure.h

package info (click to toggle)
mysql-workbench 6.3.8%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 113,932 kB
  • ctags: 87,814
  • sloc: ansic: 955,521; cpp: 427,465; python: 59,728; yacc: 59,129; xml: 54,204; sql: 7,091; objc: 965; makefile: 638; sh: 613; java: 237; perl: 30; ruby: 6; php: 1
file content (142 lines) | stat: -rw-r--r-- 4,239 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/* 
 * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; version 2 of the
 * License.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301  USA
 */

#ifndef _CONNECTION_FIGURE_H_
#define _CONNECTION_FIGURE_H_


#include "mdc.h"
#include <grts/structs.model.h>

namespace wbfig {
  class FigureEventHub;
  
  class ConnectionLineLayouter : public mdc::OrthogonalLineLayouter
  {
    typedef mdc::OrthogonalLineLayouter super;

    virtual std::vector<mdc::ItemHandle*> create_handles(mdc::Line *line, mdc::InteractionLayer *ilayer);

    virtual bool update_start_point();
    virtual bool update_end_point();

    virtual bool handle_dragged(mdc::Line *line, mdc::ItemHandle *handle, const base::Point &pos, bool dragging);

  public:
    enum Type
    {
      NormalLine,
      ZLine
    };

  private:
    Type _type;

    virtual std::vector<base::Point> get_points_for_subline(int subline);

  public:
    ConnectionLineLayouter(mdc::Connector *sconn, mdc::Connector *econn);

    void set_type(Type type);
    Type get_type() const { return _type; }
  };


  class Connection : public mdc::Line
  {
    typedef mdc::Line super;
  public:
    enum DiamondType
    {
      None,
      Filled,
      LeftEmpty,
      RightEmpty,
      Empty
    };
    enum CaptionPos
    {
      Below,
      Above,
      Middle
    };

    Connection(mdc::Layer *layer, FigureEventHub *hub, model_Object *represented_object);

    void set_splitted(bool flag);

    base::Point get_middle_caption_pos(const base::Size &size, CaptionPos pos);
    base::Point get_start_caption_pos(const base::Size &size);
    base::Point get_end_caption_pos(const base::Size &size);

    void set_start_dashed(bool flag);
    void set_end_dashed(bool flag);

    virtual void render(mdc::CairoCtx *cr);
    virtual void render_gl(mdc::CairoCtx *cr); 

    void set_start_figure(mdc::CanvasItem *item);
    void set_end_figure(mdc::CanvasItem *item);
    mdc::CanvasItem *get_start_figure() { return _start_figure; }
    mdc::CanvasItem *get_end_figure() { return _end_figure; }

    void set_diamond_type(DiamondType type);

    double get_segment_offset(int subline);
    void set_segment_offset(int subline, double offset);

    virtual bool on_click(mdc::CanvasItem *target, const base::Point &point, mdc::MouseButton button, mdc::EventState state);
    virtual bool on_double_click(mdc::CanvasItem *target, const base::Point &point, mdc::MouseButton button, mdc::EventState state);
    virtual bool on_enter(mdc::CanvasItem *target, const base::Point &point);
    virtual bool on_leave(mdc::CanvasItem *target, const base::Point &point);
    virtual bool on_button_press(mdc::CanvasItem *target, const base::Point &point, mdc::MouseButton button, mdc::EventState state);
    virtual bool on_button_release(mdc::CanvasItem *target, const base::Point &point, mdc::MouseButton button, mdc::EventState state);

    void set_center_captions(bool flag);
    bool get_center_captions() { return _center_captions; }
    virtual bool can_render_gl() { return true; }

  private:
    model_Object *_represented_object;
    FigureEventHub *_hub;
    
    mdc::CanvasItem *_start_figure;
    mdc::CanvasItem *_end_figure;

    DiamondType _diamond;
    bool _start_dashed;
    bool _end_dashed;
    bool _split;
    bool _center_captions;

    virtual bool contains_point(const base::Point &point) const;

    virtual void stroke_outline(mdc::CairoCtx *cr, float offset= 0) const;
    void stroke_outline_gl(float offset= 0);

    double get_middle_segment_angle();

    void update_layouter();

    virtual void mark_crossings(mdc::Line *line);
  };

};

#endif