My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
element.h
Go to the documentation of this file.
1 /***************************************************************************
2  element.h
3  -----------
4  begin : Sat Sep 20 2003
5  copyright : (C) 2003 by Michael Margraf
6  email : michael.margraf@alumni.tu-berlin.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef ELEMENT_H
19 #define ELEMENT_H
20 
21 #include <qpen.h>
22 #include <qbrush.h>
23 
24 class Node;
25 class QPainter;
26 class WireLabel;
27 
28 
29 struct Line {
30  Line(int _x1, int _y1, int _x2, int _y2, QPen _style)
31  : x1(_x1), y1(_y1), x2(_x2), y2(_y2), style(_style) {};
32  int x1, y1, x2, y2;
33  QPen style;
34 };
35 
36 struct Arc {
37  Arc(int _x, int _y, int _w, int _h, int _angle, int _arclen, QPen _style)
38  : x(_x), y(_y), w(_w), h(_h), angle(_angle),
39  arclen(_arclen), style(_style) {};
40  int x, y, w, h, angle, arclen;
41  QPen style;
42 };
43 
44 struct Area {
45  Area(int _x, int _y, int _w, int _h, QPen _Pen,
46  QBrush _Brush = QBrush(Qt::NoBrush))
47  : x(_x), y(_y), w(_w), h(_h), Pen(_Pen), Brush(_Brush) {};
48  int x, y, w, h;
49  QPen Pen;
50  QBrush Brush; // filling style/color
51 };
52 
53 struct Port {
54  Port() {};
55  Port(int _x, int _y, bool _avail=true) : x(_x), y(_y), avail(_avail) {
56  Type=""; Connection=0;};
57  int x, y;
58  bool avail;
59  QString Type;
61 };
62 
63 struct Text {
64  Text(int _x, int _y, const QString& _s, QColor _Color = QColor(0,0,0),
65  float _Size = 10.0, float _mCos=1.0, float _mSin=0.0)
66  : x(_x), y(_y), s(_s), Color(_Color), Size(_Size),
67  mSin(_mSin), mCos(_mCos) { over = under = false; };
68  int x, y;
69  QString s;
70  QColor Color;
71  float Size, mSin, mCos; // font size and rotation coefficients
72  bool over, under; // text attributes
73 };
74 
75 struct Property {
76  Property(const QString& _Name="", const QString& _Value="",
77  bool _display=false, const QString& Desc="")
78  : Name(_Name), Value(_Value), display(_display), Description(Desc) {};
79  QString Name, Value;
80  bool display; // show on schematic or not ?
81  QString Description;
82 };
83 
84 
85 // valid values for Element.Type
86 // The 4 least significant bits of each value are reserved for special
87 // additionals !!!
88 #define isDummy 0
89 #define isSpecialMask -16
90 
91 #define isComponent 0x30000
92 #define isComponentText 0x30002
93 #define isAnalogComponent 0x10000
94 #define isDigitalComponent 0x20000
95 
96 #define isGraph 0x0020
97 #define isNode 0x0040
98 #define isMarker 0x0080
99 #define isWire 0x0100
100 
101 #define isPainting 0x2000
102 #define isPaintingResize 0x2001
103 
104 #define isLabel 0x4000
105 #define isHWireLabel 0x4020
106 #define isVWireLabel 0x4040
107 #define isNodeLabel 0x4080
108 #define isMovingLabel 0x4001
109 #define isHMovingLabel 0x4002
110 #define isVMovingLabel 0x4004
111 
112 #define isDiagram 0x8000
113 #define isDiagramResize 0x8001
114 #define isDiagramHScroll 0x8002
115 #define isDiagramVScroll 0x8003
116 
117 
118 
119 class Element {
120 public:
121  Element();
122  virtual ~Element();
123 
124  virtual void paintScheme(QPainter*);
125  virtual void setCenter(int, int, bool relative=false);
126  virtual void getCenter(int&, int&);
127 
129  int Type; // whether it is Component, Wire, ...
130  int cx, cy, x1, y1, x2, y2; // center and relative boundings
131 };
132 
133 
134 // label for Node and Wire classes
135 class Conductor : public Element {
136 public:
138 };
139 
140 #endif