Qucs-GUI  0.0.18
 All Data Structures 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 
37 #ifndef ELEMENT_H
38 #define ELEMENT_H
39 
40 #include <QPen>
41 #include <QBrush>
42 
43 class Node;
44 class QPainter;
45 class WireLabel;
46 class Schematic;
47 
48 struct Line {
49  Line(int _x1, int _y1, int _x2, int _y2, QPen _style)
50  : x1(_x1), y1(_y1), x2(_x2), y2(_y2), style(_style) {};
51  int x1, y1, x2, y2;
52  QPen style;
53 };
54 
55 struct Arc {
56  Arc(int _x, int _y, int _w, int _h, int _angle, int _arclen, QPen _style)
57  : x(_x), y(_y), w(_w), h(_h), angle(_angle),
58  arclen(_arclen), style(_style) {};
59  int x, y, w, h, angle, arclen;
60  QPen style;
61 };
62 
63 struct Area {
64  Area(int _x, int _y, int _w, int _h, QPen _Pen,
65  QBrush _Brush = QBrush(Qt::NoBrush))
66  : x(_x), y(_y), w(_w), h(_h), Pen(_Pen), Brush(_Brush) {};
67  int x, y, w, h;
68  QPen Pen;
69  QBrush Brush; // filling style/color
70 };
71 
72 struct Port {
73  Port() {};
74  Port(int _x, int _y, bool _avail=true) : x(_x), y(_y), avail(_avail) {
75  Type=""; Connection=0;};
76  int x, y;
77  bool avail;
78  QString Type;
80 };
81 
82 struct Text {
83  Text(int _x, int _y, const QString& _s, QColor _Color = QColor(0,0,0),
84  float _Size = 10.0, float _mCos=1.0, float _mSin=0.0)
85  : x(_x), y(_y), s(_s), Color(_Color), Size(_Size),
86  mSin(_mSin), mCos(_mCos) { over = under = false; };
87  int x, y;
88  QString s;
89  QColor Color;
90  float Size, mSin, mCos; // font size and rotation coefficients
91  bool over, under; // text attributes
92 };
93 
94 struct Property {
95  Property(const QString& _Name="", const QString& _Value="",
96  bool _display=false, const QString& Desc="")
97  : Name(_Name), Value(_Value), display(_display), Description(Desc) {};
98  QString Name, Value;
99  bool display; // show on schematic or not ?
100  QString Description;
101 };
102 
103 
104 // valid values for Element.Type
105 // The 4 least significant bits of each value are reserved for special
106 // additionals !!!
107 #define isDummyElement 0
108 #define isSpecialMask -16
109 
110 #define isComponent 0x30000
111 #define isComponentText 0x30002
112 #define isAnalogComponent 0x10000
113 #define isDigitalComponent 0x20000
114 
115 #define isGraph 0x0020
116 #define isNode 0x0040
117 #define isMarker 0x0080
118 #define isWire 0x0100
119 
120 #define isPainting 0x2000
121 #define isPaintingResize 0x2001
122 
123 #define isLabel 0x4000
124 #define isHWireLabel 0x4020
125 #define isVWireLabel 0x4040
126 #define isNodeLabel 0x4080
127 #define isMovingLabel 0x4001
128 #define isHMovingLabel 0x4002
129 #define isVMovingLabel 0x4004
130 
131 #define isDiagram 0x8000
132 #define isDiagramResize 0x8001
133 #define isDiagramHScroll 0x8002
134 #define isDiagramVScroll 0x8003
135 
136 
142 class Element {
143 public:
144  Element();
145  virtual ~Element();
146 
147  virtual void paintScheme(Schematic*);
148  virtual void setCenter(int, int, bool relative=false);
149  virtual void getCenter(int&, int&);
150 
152  int Type; // whether it is Component, Wire, ...
153  int cx, cy, x1, y1, x2, y2; // center and relative boundings
154 };
155 
156 
161 class Conductor : public Element {
162 public:
164 };
165 
166 #endif
int y
Definition: element.h:86
int h
Definition: element.h:58
int arclen
Definition: element.h:58
int x
Definition: element.h:58
Property(const QString &_Name="", const QString &_Value="", bool _display=false, const QString &Desc="")
Definition: element.h:95
int y1
Definition: element.h:50
int Type
Definition: element.h:152
QPen style
Definition: element.h:60
Definition: element.h:55
Node * Connection
Definition: element.h:79
Definition: node.h:30
int w
Definition: element.h:66
int y1
Definition: element.h:153
Area(int _x, int _y, int _w, int _h, QPen _Pen, QBrush _Brush=QBrush(Qt::NoBrush))
Definition: element.h:64
label for Node and Wire classes
Definition: element.h:161
bool under
Definition: element.h:91
int y
Definition: element.h:58
int h
Definition: element.h:66
Port(int _x, int _y, bool _avail=true)
Definition: element.h:74
int y2
Definition: element.h:153
Definition: element.h:72
int x1
Definition: element.h:153
Element()
Definition: element.cpp:20
bool display
Definition: element.h:99
float Size
Definition: element.h:90
int x
Definition: element.h:66
QString Value
Definition: element.h:97
int x
Definition: element.h:86
int cx
Definition: element.h:153
QString Type
Definition: element.h:78
int x1
Definition: element.h:50
int y
Definition: element.h:75
int x2
Definition: element.h:50
int angle
Definition: element.h:58
QPen Pen
Definition: element.h:68
bool isSelected
Definition: element.h:151
virtual ~Element()
Definition: element.cpp:27
Arc(int _x, int _y, int _w, int _h, int _angle, int _arclen, QPen _style)
Definition: element.h:56
Line(int _x1, int _y1, int _x2, int _y2, QPen _style)
Definition: element.h:49
Definition: element.h:63
Definition: element.h:82
QBrush Brush
Definition: element.h:69
virtual void getCenter(int &, int &)
Definition: element.cpp:39
Definition: element.h:48
Superclass of all schematic drawing elements.
Definition: element.h:142
Port()
Definition: element.h:73
QString Name
Definition: element.h:97
bool over
Definition: element.h:91
int cy
Definition: element.h:153
QColor Color
Definition: element.h:89
int w
Definition: element.h:58
WireLabel * Label
Definition: element.h:163
float mCos
Definition: element.h:90
bool avail
Definition: element.h:77
QPen style
Definition: element.h:52
float mSin
Definition: element.h:90
virtual void paintScheme(Schematic *)
Definition: element.cpp:31
QString Description
Definition: element.h:100
int y
Definition: element.h:66
Text(int _x, int _y, const QString &_s, QColor _Color=QColor(0, 0, 0), float _Size=10.0, float _mCos=1.0, float _mSin=0.0)
Definition: element.h:83
int x2
Definition: element.h:153
int x
Definition: element.h:75
QString s
Definition: element.h:88
virtual void setCenter(int, int, bool relative=false)
Definition: element.cpp:35
int y2
Definition: element.h:50