Qucs-GUI  0.0.18
diagram.h
Go to the documentation of this file.
1 /***************************************************************************
2  diagram.h
3  -----------
4  begin : Thu Oct 2 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 *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17
18 #ifndef DIAGRAM_H
19 #define DIAGRAM_H
20
21 #include "graph.h"
22 #include "marker.h"
23 #include "element.h"
24 #include "viewpainter.h"
25
26 #include <QFile>
28 #include <QTextStream>
29 #include <Q3PtrList>
30
31 #define MIN_SCROLLBAR_SIZE 8
32
33 #define INVALID_STR QObject::tr(" <invalid>")
34
35 // ------------------------------------------------------------
36 // Enlarge memory block if neccessary.
37 #define FIT_MEMORY_SIZE \
38  if(p >= p_end) { \
39  Size += 256; \
40  tmp = p - g->ScrPoints; \
41  p = p_end = g->ScrPoints = (float*)realloc(g->ScrPoints, Size*sizeof(float)); \
42  p += tmp; \
43  p_end += Size - 9; \
44  } \
45
46
47 struct Axis {
48  double min, max; // least and greatest values of all graph data
49  double low, up; // the limits of the diagram
50  bool log; // in "rectdiagram": logarithmic or linear
51  QString Label;
52  int numGraphs; // counts number of graphs using this axis
53  bool GridOn;
54
55  bool autoScale; // manual limits or auto-scale ?
56  double limit_min, limit_max, step; // if not auto-scale
57 };
58
59
60 class Diagram : public Element {
61 public:
62  Diagram(int _cx=0, int _cy=0);
63  virtual ~Diagram();
64
65  virtual Diagram* newOne();
66  virtual int calcDiagram() { return 0; };
67  virtual void calcCoordinate
68  (double* &, double* &, double* &, float*, float*, Axis*) {};
69  virtual void calcLimits() {};
70
71  virtual void paint(ViewPainter*);
72  void setCenter(int, int, bool relative=false);
73  void getCenter(int&, int&);
74  void paintScheme(Schematic*);
75  void Bounding(int&, int&, int&, int&);
76  bool getSelected(int, int);
77  bool resizeTouched(float, float, float);
78  QString save();
80
81  void getAxisLimits(Graph*);
82  void updateGraphData();
84  void recalcGraphData();
86  int loadIndepVarData(const QString&, char*, Axis*, Graph*);
87  bool sameDependencies(Graph*, Graph*);
88  int checkColumnWidth(const QString&, const QFontMetrics&, int, int, int);
89
90  virtual bool insideDiagram(float, float);
91
92  QString Name; // identity of diagram type (e.g. Polar), used for saving etc.
93  QPen GridPen;
94
95  Q3PtrList<Graph> Graphs;
96  Q3PtrList<struct Arc> Arcs;
97  Q3PtrList<Line> Lines;
98  Q3PtrList<Text> Texts;
99
100  int x3, y3;
101  Axis xAxis, yAxis, zAxis; // axes (x, y left, y right)
102  int State; // to remember which resize area was touched
103
104  bool hideLines; // for "Rect3D": hide invisible lines ?
105  int rotX, rotY, rotZ; // for "Rect3D": rotation around x, y and z axis
106
107 protected:
108  void calcSmithAxisScale(Axis*, int&, int&);
109  void createSmithChart(Axis*, int Mode=7);
110  void calcPolarAxisScale(Axis*, double&, double&, double&);
111  void createPolarDiagram(Axis*, int Mode=3);
112
113  bool calcAxisScale(Axis*, double&, double&, double&, double&, double);
114  bool calcAxisLogScale(Axis*, int&, double&, double&, double&, int);
115  bool calcYAxis(Axis*, int);
116  virtual void createAxisLabels();
117
118  int regionCode(float, float);
119  virtual void clip(float* &);
120  void rectClip(float* &);
121
122  virtual void calcData(Graph*);
123
124 private:
126 };
127
128 #endif
int State
Definition: diagram.h:102
Diagram(int _cx=0, int _cy=0)
Definition: diagram.cpp:45
virtual bool insideDiagram(float, float)
Definition: diagram.cpp:305
Axis xAxis
Definition: diagram.h:101
void getCenter(int &, int &)
Definition: diagram.cpp:1184
Defines drawing elements for schematics.
void recalcGraphData()
Definition: diagram.cpp:769
int regionCode(float, float)
Definition: diagram.cpp:287
bool load(const QString &, QTextStream *)
Definition: diagram.cpp:1243
virtual void createAxisLabels()
Definition: diagram.cpp:157
Definition: graph.h:57
int rotX
Definition: diagram.h:105
QString Name
Definition: diagram.h:92
bool hideLines
Definition: diagram.h:104
bool sameDependencies(Graph *, Graph *)
Definition: diagram.cpp:1136
double limit_min
Definition: diagram.h:56
int rotZ
Definition: diagram.h:105
bool GridOn
Definition: diagram.h:53
void setCenter(int, int, bool relative=false)
Definition: diagram.cpp:1173
void getAxisLimits(Graph *)
Definition: diagram.cpp:661
QPen GridPen
Definition: diagram.h:93
virtual void calcLimits()
Definition: diagram.h:69
virtual void clip(float *&)
Definition: diagram.cpp:395
void rectClip(float *&)
Definition: diagram.cpp:315
virtual void calcCoordinate(double *&, double *&, double *&, float *, float *, Axis *)
Definition: diagram.h:68
bool getSelected(int, int)
Definition: diagram.cpp:631
int Bounding_x1
Definition: diagram.h:125
void createSmithChart(Axis *, int Mode=7)
Definition: diagram.cpp:1415
void createPolarDiagram(Axis *, int Mode=3)
Definition: diagram.cpp:1589
int numGraphs
Definition: diagram.h:52
Axis zAxis
Definition: diagram.h:101
int loadVarData(const QString &, Graph *)
Definition: diagram.cpp:828
Q3PtrList< Graph > Graphs
Definition: diagram.h:95
Q3PtrList< struct Arc > Arcs
Definition: diagram.h:96
void Bounding(int &, int &, int &, int &)
Definition: diagram.cpp:622
Definition: diagram.h:47
bool log
Definition: diagram.h:50
int x3
Definition: diagram.h:100
int checkColumnWidth(const QString &, const QFontMetrics &, int, int, int)
Definition: diagram.cpp:1154
bool calcAxisLogScale(Axis *, int &, double &, double &, double &, int)
Definition: diagram.cpp:1783
Superclass of all schematic drawing elements.
Definition: element.h:142
QString save()
Definition: diagram.cpp:1197
int Bounding_x2
Definition: diagram.h:125
double max
Definition: diagram.h:48
virtual void paint(ViewPainter *)
Definition: diagram.cpp:87
double limit_max
Definition: diagram.h:56
QString Label
Definition: diagram.h:51
int y3
Definition: diagram.h:100
Q3PtrList< Text > Texts
Definition: diagram.h:98
virtual void calcData(Graph *)
Definition: diagram.cpp:464
bool calcAxisScale(Axis *, double &, double &, double &, double &, double)
Definition: diagram.cpp:1665
virtual ~Diagram()
Definition: diagram.cpp:81
Axis yAxis
Definition: diagram.h:101
void updateGraphData()
Definition: diagram.cpp:800
virtual Diagram * newOne()
Definition: diagram.cpp:1191
double step
Definition: diagram.h:56
Definition: diagram.cpp:724
void calcSmithAxisScale(Axis *, int &, int &)
Definition: diagram.cpp:1395
virtual int calcDiagram()
Definition: diagram.h:66
double up
Definition: diagram.h:49
int loadIndepVarData(const QString &, char *, Axis *, Graph *)
Definition: diagram.cpp:1049
void calcPolarAxisScale(Axis *, double &, double &, double &)
Definition: diagram.cpp:1552
bool autoScale
Definition: diagram.h:55
bool calcYAxis(Axis *, int)
Definition: diagram.cpp:1874
Q3PtrList< Line > Lines
Definition: diagram.h:97
int rotY
Definition: diagram.h:105
int Bounding_y1
Definition: diagram.h:125
double low
Definition: diagram.h:49
double min
Definition: diagram.h:48
void paintScheme(Schematic *)
Definition: diagram.cpp:150
bool resizeTouched(float, float, float)
Definition: diagram.cpp:642
int Bounding_y2
Definition: diagram.h:125