~illusions-hu/soundbox/trunk

« back to all changes in this revision

Viewing changes to scr/connector/co_unit.h

  • Committer: illusions.hu at gmail
  • Date: 2010-12-18 10:09:41 UTC
  • Revision ID: illusions.hu@gmail.com-20101218100941-qygg337sqghpxoz2
Connector files added

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
Copyright (C) 2010 Laszlo Simon <laszlo.simon@gmail.com>
 
3
                   Esthefan Maleki <illusions.hu@gmail.com>
 
4
This file is part of the SOUNDBOX project.
 
5
 
 
6
SOUNDBOX is free software: you can redistribute it and/or modify
 
7
it under the terms of the GNU General Public License as published by
 
8
the Free Software Foundation version 3 of the License.
 
9
 
 
10
SOUNDBOX is distributed in the hope that it will be useful,
 
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
13
GNU General Public License for more details.
 
14
 
 
15
You should have received a copy of the GNU General Public License
 
16
along with SOUNDBOX. If not, see <http://www.gnu.org/licenses/>.
 
17
 
 
18
See http://www.illusions.hu for further details.
 
19
*****************************************************************************/
 
20
 
 
21
#ifndef CO_UNIT_H
 
22
#define CO_UNIT_H
 
23
 
 
24
#include <Math>
 
25
#include <QObject>
 
26
#include <QBitmap>
 
27
#include <QPoint> 
 
28
#include <QCanvas>
 
29
#include <QPopupMenu>
 
30
#include <QMouseEvent>
 
31
#include "co_connectarray.h"
 
32
#include "co_joint.h"
 
33
#include "co_flowsheet.h"
 
34
 
 
35
// class for operator unit elements on the flowsheet
 
36
class TGUnit {
 
37
 
 
38
private:
 
39
  bool onMove;
 
40
  QPoint prevCoord;
 
41
  int Left,Top,Width,Height;
 
42
  QObject parent;
 
43
  QBitmap bmp;
 
44
  void createPopup();
 
45
  
 
46
  // removes the unit from the flowsheet
 
47
  void DeleteClick(QObject Sender);
 
48
  
 
49
  //flips the unit
 
50
  void FlipClick(QObject Sender);
 
51
  
 
52
  // rotates the unit by 90 degrees clockwise
 
53
  void cw90Click(QObject Sender);
 
54
  
 
55
  // rotates the unit by 90 degrees counter clock wise
 
56
  void ccw90Click(QObject Sender);
 
57
 
 
58
  // rotates the unit by 180 degress
 
59
  void rot180click(QObject Sender);
 
60
  
 
61
  void knotsAlign(void);
 
62
  
 
63
  void setBoundSize(int l,t,w,h);
 
64
  void FindActiveTap(int x,y);
 
65
 
 
66
protected:
 
67
 
 
68
  // sets the size of the bounding rectangle 
 
69
  void setSize(int w,h);
 
70
  
 
71
  // recalculates the coordinates
 
72
  void CoordReCalc(int &x,&y);
 
73
  
 
74
  void drawElipse(int x,y,R);
 
75
 
 
76
  void drawRectangle(int x0,y0,x1,y1);
 
77
  void drawline(int x0,y0,x1,y1);
 
78
  void drawRender(QCanvas Canvas);
 
79
 
 
80
  void MouseDown(TMouseButton Button, TShiftState Shift: int X, Y);
 
81
  void MouseUp(TMouseButton Button, TShiftState Shift: int X, Y);
 
82
  void MouseMove(TShiftState Shift, int X, Y);  
 
83
 
 
84
public:
 
85
  // name of the unit
 
86
  String name;
 
87
  
 
88
  // sequence number
 
89
  int SeqNum;
 
90
  
 
91
  // zooming factor
 
92
  int zoomFactor ;
 
93
  
 
94
  // 1 - upward / felfel�
 
95
  // 2 - rightward / jobbra
 
96
  // 3 - downwards / lefel�
 
97
  // 4 - leftward // balra
 
98
  direction : integer;
 
99
  
 
100
  bool flip;
 
101
  
 
102
  TGConnectArray taps;
 
103
  int activetap;
 
104
  TGJointArray  Knots;
 
105
  bool overed;
 
106
  QPopupMenu popupmenu;
 
107
  
 
108
  onDrawClick : procedure(Sender : TObject; x,y : integer) of object;
 
109
  
 
110
  QMouseEvent onMouseDown;
 
111
  QMouseEvent onMouseUp;
 
112
  QMouseMoveEvent onMouseMove;
 
113
 
 
114
  TGUnit(TGConnectArray ts, QString n, int SN,ZF, TWinControl parent);
 
115
  
 
116
  void paint(QCanvas canvas); // virtual;
 
117
   
 
118
  void draw(QCanvas canvas);
 
119
 
 
120
  // returns if the mouse is over the unit
 
121
  bool isOvered(QPoint mouseCord);
 
122
 
 
123
  void Over(int X, Y);
 
124
 
 
125
  bool Drop(TGJoint source);
 
126
  
 
127
  void unConnect(TGJoint p);
 
128
} // class
 
129
 
 
130
#endif // CO_UNIT_H
 
 
b'\\ No newline at end of file'