summaryrefslogtreecommitdiff
path: root/iup/srcpplot/iuppplot.hpp
blob: 62e3db7f55b41a3bac13114fca6887864a08e2b4 (plain)
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
/*
 * IupPPlot component - private include file
 *
 * Description : A component, derived from PPlot and IUP canvas
 *      Remark : Depend on libs IUP, CD, IUPCD
 */


#ifndef __IUP_PPLOT_H
#define __IUP_PPLOT_H

/*
  PPainterIup class definition
*/


class PostPainterCallbackIup: public PDrawer
{
  public:
    PostPainterCallbackIup(PPlot &inPPlot, Ihandle* inHandle);
    virtual bool Draw (Painter &inPainter);
  protected:
    Ihandle *_ih;   // IUP handle
};

class PrePainterCallbackIup: public PDrawer
{
  public:
    PrePainterCallbackIup(PPlot &inPPlot, Ihandle* inHandle);
    virtual bool Draw (Painter &inPainter);
  protected:
    Ihandle *_ih;   // IUP handle
};

class PDeleteInteractionIup: public PDeleteInteraction
{
  public:
    PDeleteInteractionIup(PPlot &inPPlot, Ihandle* inHandle):
    PDeleteInteraction(inPPlot), _ih(inHandle) {}

  protected:
    Ihandle *_ih;   // IUP handle
    bool DeleteNotify(int inIndex, int inSampleIndex, PlotDataBase *inXData, PlotDataBase *inYData);
};

class PSelectionInteractionIup: public PSelectionInteraction
{
  public:
    PSelectionInteractionIup(PPlot &inPPlot, Ihandle* inHandle):
    PSelectionInteraction(inPPlot), _ih(inHandle) {}

  protected:
    Ihandle *_ih;   // IUP handle
    bool SelectNotify(int inIndex, int inSampleIndex, PlotDataBase *inXData, PlotDataBase *inYData, bool inSelect);
};

class PEditInteractionIup: public PEditInteraction
{
  public:
    PEditInteractionIup (PPlot &inPPlot, Ihandle* inHandle):
    PEditInteraction(inPPlot), _ih(inHandle) {}

    virtual bool Impl_HandleKeyEvent (const PKeyEvent &inEvent);
    virtual bool Impl_Calculate (Painter &inPainter, PPlot& inPPlot);

  protected:
    Ihandle *_ih;   // IUP handle
    void HandleCursorKey (const PlotDataSelection *inPlotDataSelection, PlotDataBase *inXData, PlotDataBase *inYData, int inIndex);
    bool EditNotify(int inIndex, int inSampleIndex, float inX, float inY, float *inNewX, float *inNewY);
};

class InteractionContainerIup: public InteractionContainer
{
  public:
    InteractionContainerIup(PPlot &inPPlot, Ihandle* inHandle);

    PZoomInteraction mZoomInteraction;
    PSelectionInteractionIup mSelectionInteraction;
    PEditInteractionIup mEditInteraction;
    PDeleteInteractionIup mDeleteInteraction;
    PCrosshairInteraction mCrosshairInteraction;

    PostPainterCallbackIup mPostPainterCallback;
    PrePainterCallbackIup mPrePainterCallback;
};

class PPainterIup: public Painter
{
  public:
    PPainterIup(Ihandle *ih);
    virtual ~PPainterIup();
    cdCanvas *_cdcanvas;       /* iup drawing surface */
    cdCanvas *_cddbuffer;      /* double buffer drawing surface */
    PPlot _plot;               /* plot data holder */
    int _redraw;               /* must update the double buffer before flush */
    int _currentDataSetIndex;  /* dataset index used for DS_ attributes in SetAttribute and GetAttribute */

    // Called from C functions
    void Draw(int force);   // paint the stuff
    void Resize(); // called when resizing
    void MouseButton(int btn, int stat, int x, int y, char *r); // mouse event
    void MouseMove(int x, int y); // mouse event
    void KeyPress(int c, int press); // keyboard event
    void DrawTo(cdCanvas *usrCnv);   // send plot to some user defined device

  protected:
    InteractionContainer *_InteractionContainer;
    Ihandle *_ih;   // IUP handle
    short int _mouseDown;
    short int _mouse_ALT;
    short int _mouse_SHIFT;
    short int _mouse_CTRL;

    PPainterIup() { };

    virtual void FillArrow(int inX1, int inY1, int inX2, int inY2, int inX3, int inY3);
    virtual void DrawLine(float inX1, float inY1, float inX2, float inY2);
    virtual void FillRect(int inX, int inY, int inW, int inH);
    virtual void InvertRect(int inX, int inY, int inW, int inH);
    virtual void SetClipRect(int inX, int inY, int inW, int inH);
    virtual long GetWidth() const;
    virtual long GetHeight() const;
    virtual void SetLineColor(int inR, int inG, int inB);
    virtual void SetFillColor(int inR, int inG, int inB);
    virtual long CalculateTextDrawSize(const char *inString);
    virtual long GetFontHeight() const;
    virtual void DrawText(int inX, int inY, short align, const char *inString);
    virtual void DrawRotatedText(int inX, int inY, float inDegrees,
                                 short align, const char *inString);
    virtual void SetStyle(const PStyle &inStyle);

  private:

}; // PPainterIup


#endif /* #ifndef __IUP_PPLOT_HPP */