source: orange/source/orangeqt/point.sip @ 9361:2a7fa63580e2

Revision 9361:2a7fa63580e2, 2.6 KB checked in by miha <miha.stajdohar@…>, 2 years ago (diff)

Fixed selections to marked only.

Line 
1// DataPoint is implemented as a Python 2-element tuple.
2%MappedType DataPoint /DocType="tuple-of-float-float"/
3{
4%TypeHeaderCode
5#include "point.h"
6%End
7
8%ConvertFromTypeCode
9    // Create the tuple.
10    return Py_BuildValue((char *)"dd", sipCpp->x, sipCpp->y);
11%End
12
13%ConvertToTypeCode
14    // Check the type if that is all that is required.
15    if (sipIsErr == NULL)
16        return (PyTuple_Size(sipPy) == 2);
17   
18    DataPoint* qp = new DataPoint();
19
20    PyArg_ParseTuple(sipPy, "dd", &qp->x, &qp->y);
21    *sipCppPtr = qp;
22   
23    return sipGetState(sipTransferObj);
24%End
25};
26
27class Point : QGraphicsObject
28{
29   
30%TypeHeaderCode
31#include "point.h"
32%End
33
34public:
35    enum DisplayMode
36    {
37        DisplayPixmap,
38        DisplayPath
39    };
40   
41  enum Symbol {
42    NoSymbol = -1,
43    Ellipse = 0,
44    Rect = 1,
45    Diamond = 2,
46    Triangle = 3,
47    DTriangle = 4,
48    UTriangle = 5,
49    LTriangle = 6,
50    RTriangle = 7,
51    Cross = 8,
52    XCross = 9,
53    HLine = 10,
54    VLine = 11,
55    Star1 = 12,
56    Star2 = 13,
57    Hexagon = 14,
58    UserStyle = 1000
59  };
60
61    enum StateFlag
62    {
63        Normal = 0x00,
64        Marked = 0x01,
65        Selected = 0x02
66    };
67
68    typedef QFlags<Point::StateFlag> State;
69 
70    Point(QGraphicsItem* parent /TransferThis/ = 0);
71    Point(int symbol, QColor color, int size, QGraphicsItem* parent /TransferThis/ = 0);
72    virtual ~Point();
73   
74    virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
75    virtual QRectF boundingRect() const;
76   
77    void set_symbol(int symbol);
78    int symbol() const;
79   
80    void set_color(const QColor& color);
81    QColor color() const;
82   
83    void set_size(int size);
84    int size() const;
85   
86    void set_display_mode(DisplayMode mode);
87    DisplayMode display_mode() const;
88
89    void set_state(State state);
90    State state() const;
91    void set_state_flag(StateFlag flag, bool on);
92    bool state_flag(StateFlag flag) const;
93   
94    void set_selected(bool selected);
95    bool is_selected() const;
96
97    void set_marked(bool marked);
98    bool is_marked() const;
99   
100    bool is_transparent();
101    void set_transparent(bool transparent);
102   
103    DataPoint coordinates() const;
104    void set_coordinates(const DataPoint& data_point);   
105   
106    /**
107    * Creates a path from a symbol and a size
108    *
109    * @param symbol the point symbol to use
110    * @param size the size of the resulting path
111    * @return a path that can be used in a QGraphicsPathItem or in QPainter::drawPath()
112    **/
113    static QPainterPath path_for_symbol(int symbol, int size);
114   
115    static QPixmap pixmap_for_symbol(int symbol, QColor color, int size);
116    static void clear_cache();
117};
Note: See TracBrowser for help on using the repository browser.