My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
symbolwidget.h
Go to the documentation of this file.
1 /***************************************************************************
2  symbolwidget.h
3  ----------------
4  begin : Sat May 29 2005
5  copyright : (C) 2005 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 SYMBOLWIDGET_H
19 #define SYMBOLWIDGET_H
20 
21 #include <qwidget.h>
22 #include <qsize.h>
23 #include <qpen.h>
24 #include <qbrush.h>
25 #include <qcolor.h>
26 #include <qstring.h>
27 #include <qptrlist.h>
28 
29 class QDragObject;
30 class QPaintEvent;
31 class QSizePolicy;
32 
33 
34 struct Line {
35  Line(int _x1, int _y1, int _x2, int _y2, QPen _style)
36  : x1(_x1), y1(_y1), x2(_x2), y2(_y2), style(_style) {};
37  int x1, y1, x2, y2;
38  QPen style;
39 };
40 
41 struct Arc {
42  Arc(int _x, int _y, int _w, int _h, int _angle, int _arclen, QPen _style)
43  : x(_x), y(_y), w(_w), h(_h), angle(_angle),
44  arclen(_arclen), style(_style) {};
45  int x, y, w, h, angle, arclen;
46  QPen style;
47 };
48 
49 struct Area {
50  Area(int _x, int _y, int _w, int _h, QPen _Pen,
51  QBrush _Brush = QBrush(Qt::NoBrush))
52  : x(_x), y(_y), w(_w), h(_h), Pen(_Pen), Brush(_Brush) {};
53  int x, y, w, h;
54  QPen Pen;
55  QBrush Brush; // filling style/color
56 };
57 
58 struct Text {
59  Text(int _x, int _y, const QString& _s, QColor _Color = QColor(0,0,0),
60  float _Size = 10.0, float _mCos=1.0, float _mSin=0.0)
61  : x(_x), y(_y), s(_s), Color(_Color), Size(_Size) {};
62  int x, y;
63  QString s;
64  QColor Color;
65  float Size;
66 };
67 
68 
69 
70 class SymbolWidget : public QWidget {
71  Q_OBJECT
72 public:
73  SymbolWidget(QWidget *parent = 0);
74  ~SymbolWidget();
75 
76  QString theModel();
77  int setSymbol(const QString&, const QString&, const QString&);
78  int createSymbol(const QString&, const QString&);
79 
80  // component properties
81  int Text_x, Text_y;
84 
85 protected:
86  void mouseMoveEvent(QMouseEvent*);
87 
88 private:
89  void paintEvent(QPaintEvent*);
90 
91  int analyseLine(const QString&);
92  bool getIntegers(const QString&,
93  int *i1=0, int *i2=0, int *i3=0, int *i4=0, int *i5=0, int *i6=0);
94  bool getPen (const QString&, QPen&, int);
95  bool getBrush(const QString&, QBrush&, int);
96 
97  QDragObject *myDragObject;
98 
99  QString PaintText, DragNDropText;
100  int TextWidth, DragNDropWidth, TextHeight;
101  int cx, cy, x1, x2, y1, y2;
102  QPtrList<Line> Lines;
103  QPtrList<struct Arc> Arcs;
104  QPtrList<Area> Rects, Ellips;
105  QPtrList<Text> Texts;
106 };
107 
108 #endif